Note that there are some explanatory texts on larger screens.

plurals
  1. POdocument looks cut after using itextsharp.text.pdf to merge several itextsharp.text.pdf.PdfReader objects
    text
    copied!<p>I am using iTextSharp to create a <code>List&lt;PdfReader&gt; _documents</code> with several PDF documents. After using merge on this list to create single paged document and send it to the client I see that the PDF looks cut in Adobe Reader. When I highlight the picture like this I can see it's there :</p> <p><img src="https://i.stack.imgur.com/5rRXe.jpg" alt="enter image description here"></p> <p>and if I save it it will be complete.</p> <p>If I save one of <code>PdfReader</code> in list as single PDF document - without merge - it looks good.</p> <p><img src="https://i.stack.imgur.com/7lZsF.jpg" alt="enter image description here"></p> <p>The merge function is : </p> <pre><code>public void Merge(Stream outputStream) { Document newDocument = null; try { newDocument = new Document(); // Set margins and page size for the document newDocument.SetMargins(50, 50, 50, 50); // There are a huge number of possible page sizes, including such sizes as // EXECUTIVE, LEGAL, LETTER_LANDSCAPE, and NOTE newDocument.SetPageSize(PageSize.A3 ); PdfWriter pdfWriter = PdfWriter.GetInstance(newDocument, outputStream); newDocument.Open(); PdfContentByte pdfContentByte = pdfWriter.DirectContent; if (EnablePagination) { _documents.ForEach(delegate(PdfReader doc) { _totalPages += doc.NumberOfPages; }); } int currentPage = 1; foreach (PdfReader pdfReader in _documents) { for (int page = 1; page &lt;= pdfReader.NumberOfPages; page++) { newDocument.NewPage(); PdfImportedPage importedPage = pdfWriter.GetImportedPage(pdfReader, page); pdfContentByte.AddTemplate(importedPage, 0, 0); if (EnablePagination) { pdfContentByte.BeginText(); pdfContentByte.SetFontAndSize(_baseFont, 9); pdfContentByte.ShowTextAligned(PdfContentByte.ALIGN_CENTER, string.Format("{0} of {1}", currentPage++, _totalPages), 520, 5, 0); pdfContentByte.EndText(); } } } } finally { outputStream.Flush(); if (newDocument != null) newDocument.Close(); outputStream.Close(); } } </code></pre> <p>I suspect it has something to do with <code>newDocument.SetPageSize(PageSize.A3);</code> but I am not sure and so far I can't find the solution.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload