Convert a byte[] pdf with multiple pages into a ceTe.DynamicPDF.Document

77 Views Asked by At

Is there a way to convert a byte array pdf with multiple pages into a ceTe.DynamicPDF.Document object ?

Thanks

2

There are 2 best solutions below

0
Gustavo F On

Create a new Document instance, then use MergeDocument passing your byte array.

Example here.

0
Jacob S On

I recommend using a MergeDocument instead of a Document. A PdfDocument can be created from a byte array. It retains all the pages of the PDF. The PdfDocument can be appended to a mergeDocument.

PdfDocument myPdfDoc = new PdfDocument(myByteArray);
myMergeDoc.Append(myPdfDoc);

If you specifically need a ceTe.DynamicPDF.Document you can make a MergeDocument, add the PdfDocument to it, then iterate through the pages in the MergeDocument and save them to a Document. Admittedly, that is a messy solution.

foreach (Page page in myMergeDoc.Pages)
{
    myDocument.Pages.Add(page);
}