Question

I am trying to do something really simple with ABCpdf. My goal is to add page numbers to existing PDFs (Generated through telerik - PDF export).

The problem I am having is that after reading a PDF and then saving it the file becomes corrupt.

My code:

Doc pdfDocument = new Doc();
pdfDocument.Read(path);            
MemoryStream outputMemoryStream = new MemoryStream();            
pdfDocument.Save(outputMemoryStream);
pdfDocument.Clear();
Response.BinaryWrite(outputMemoryStream.ToArray());
outputMemoryStream.Close();   

Any advice would be greatly appreciated.

I am using ABCpdf 8.

Was it helpful?

Solution

Take a look at my answer Add page numbers to a Pdf document

This explains how to add page numbering to the pdf chain.

Looking at your code the issue seams to be that you are rewritting to the current file in memory. Try reading the file in creating a new file with the added page numbering then if you need to, delete the first document and rename the second.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top