I load a pdf document that has several pages in my pdfviewer. The user can add free text annotations on few pages. I want to create a new pdf with the pages in which annotations are present along with user annotations on them. Is this possible?
I load my PDF using snippet:
var pdfDocument = new PdfDocument();
PdfDocumentBase.Merge(pdfDocument, fileStream);
MemoryStream stream = new MemoryStream();
pdfDocument.Save(stream);
I explored ExportAsImage option. However it fails to create a new stream from the above stream.
Stream[] stream = new Stream[2];
int index = 0;
foreach(var pageIndex in page.Value)
{
var image = pdfCtrl.ExportAsImage(pageIndex); //say this is 0
image.Position = 0;
stream[index++] = image;
}
PdfDocument pdfDocument = new PdfDocument();
PdfDocumentBase.Merge(pdfDocument, stream); <--fails with "
could not find valid signature ( pdf-)"
MemoryStream ms = new MemoryStream();
pdfDocument.Save(ms);