Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Well, the problem is the misconception that you can combine multiple PDF files into one by simply concatenating them. That is wrong for PDFs (just like it is wrong for most binary file formats).</p> <p>Thus, you should update your GenerateAllEvaluation_PDF method to have a PdfConcatenate instance instead of your byte Array whole, cf. <a href="http://api.itextpdf.com/itext/com/itextpdf/text/pdf/PdfConcatenate.html" rel="nofollow">http://api.itextpdf.com/itext/com/itextpdf/text/pdf/PdfConcatenate.html</a>, open each byte array returned by your GenerateEvaluationCATH_PDF method in a PdfReader, add all pages of these readers to the PdfConcatenate and eventually return the bytes generated by that class.</p> <p><strong>EDIT</strong> (I'm more into Java than C#, thus forgive minor errors)</p> <pre><code>PdfConcatenate whole = new PdfConcatenate(...); foreach (var ca in caseList) { byte[] part = null; if (ca.CaseType == "CTA") { part = GenerateEvaluationCAT_PDF(learnerID, ca.ID); } else if (ca.CaseType == "CTAH") { part = GenerateEvaluationCATH_PDF(learnerID, ca.ID); } else { part = ???; } PdfReader partReader = new PdfReader(part); whole.AddPages(partReader); partReader.Close(); } </code></pre> <p>The PdfConcatenate can be constructed with a MemoryStream from which you can retrieve the final byte[].</p> <p><strong>PS</strong>: <code>PdfConcatenate</code> may not be a part of iTextSharp version 4.x yet but it is merely a convenience wrapper of PdfCopy and PdfSmartCopy. Thus, you may simply have a look at the sources of iTextSharp (OSS after all) and be inspired: <a href="http://sourceforge.net/p/itextsharp/code/455/tree/tags/iTextSharp_5_3_3/src/core/iTextSharp/text/pdf/PdfConcatenate.cs" rel="nofollow">PdfConcatenate.cs</a>.</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