I have a PDF document and have a page number at specific position. I would like to update the page numbers. Please refer the attached documents. source.pdf and expected.pdf.
expected.pdf (167.9 KB)
source.pdf (116.6 KB)
I have a PDF document and have a page number at specific position. I would like to update the page numbers. Please refer the attached documents. source.pdf and expected.pdf.
expected.pdf (167.9 KB)
source.pdf (116.6 KB)
You can overwrite the page number stamp on each page with the White background color. Please try the code as follows:
C#
string dataDir = @"C:\Pdf\test821\";
// Open document
Document pdfDocument = new Document(dataDir + "source.pdf");
// Create page number stamp
PageNumberStamp pageNumberStamp = new PageNumberStamp();
// Whether the stamp is background
pageNumberStamp.Background = false;
pageNumberStamp.Format = "Page #";// of " + pdfDocument.Pages.Count;
pageNumberStamp.BottomMargin = pdfDocument.Pages[1].Rect.Height - 50;
pageNumberStamp.RightMargin = 65;
pageNumberStamp.HorizontalAlignment = HorizontalAlignment.Right;
pageNumberStamp.StartingNumber = 1;
// Set text properties
pageNumberStamp.TextState.Font = FontRepository.FindFont("Arial");
pageNumberStamp.TextState.FontSize = 12.0F;
pageNumberStamp.TextState.FontStyle = FontStyles.Bold;
pageNumberStamp.TextState.ForegroundColor = Aspose.Pdf.Color.Black;
pageNumberStamp.TextState.BackgroundColor = Aspose.Pdf.Color.White;
foreach(Aspose.Pdf.Page page in pdfDocument.Pages)
// Add stamp to particular page
page.AddStamp(pageNumberStamp);
// Save output document
pdfDocument.Save(dataDir + "Output.pdf");
This is the output PDF file: Output.pdf (143.6 KB)