Using the following code, I am able to write page numbers to SOME files.
Code:
var outputDocument = new PdfDocument();
var currentPageNumber = 1;
var inputDocument = PdfReader.Open(@"C:\SamplePdfs\display.pdf", PdfDocumentOpenMode.Import);
for (var i = 0; i < inputDocument.PageCount; i++)
{
PdfPage page = outputDocument.AddPage(inputDocument.Pages[i]);
XGraphics gfx = XGraphics.FromPdfPage(page);
XFont font = new XFont("Arial", 100, XFontStyle.Regular);
gfx.DrawString(Convert.ToString(currentPageNumber), font, XBrushes.Black, new XRect(0, 0, page.Width - 100, page.Height - 100), XStringFormats.BottomCenter);
currentPageNumber++;
}
outputDocument.Save(@"c:\test\sample1.pdf");
See an example pdf that I cannot write to here:
http://www.filedropper.com/newdisplay It is like the pdfPage is not accepting the DrawString command even though all the other pages are.