I'm using iText7 for .NET c#. I'm trying to create a multi page PDF document (n-number of pages) in memory where the source pdf document consists of only one page.
I can create a new document with the one page, but unable to create the additional pages as needed. I've tried
MemoryStream ms = new MemoryStream();
Stream s1 = Assembly.GetExecutingAssembly().GetManifestResourceStream("doc.pdf");
s1.CopyTo(ms)
PdfReader readerSrc = new PdfReader(ms);
PdfDocument srcPdfDoc = new PdfDocument(readerSrc);
MemoryStream msDest = new ByteArrayOutputStream();
PdfDocument destPdfDoc - new PdfDocument(new PdfWriter(msDest));
srcPdfDoc.CopyPageTo(1,1,destPdfDoc)
destPdfDoc.AddNewPage(1, new PageSize.A4)
srcPdfDoc.CopyPageTo(1,2,destPdfDoc)
But then I get an ArgumentOutOfRange exception...Index out of range...etc....
I've tried closing the destPdfDoc to then re-open it thinking that the second page hadn't been written until I close it. But then when open the destPdfDoc up the 2nd time, it has no pages. I can't figure out how to open up the destPdfDoc in like "Append" mode. If that makes sense. Bottom line, I'm lost.
I've done this using iTextSharp, but then when using the new iText7, the library changed and my old code doesn't work anymore.