We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Page number in pdf

Hi Team,


i want to use the code given at below link in vb.net
can you please send me the code

http://www.aspose.com/docs/display/pdfjava/Add+Page+Number+Stamp+in+PDF

Hi there,


Thanks for your inquiry. Please check following documentation link for details/code snippet to add page number stamp in PDF document. Hopefully it will serve the purpose.


Please feel free to contact us for any further assistance.

Best Regards,

Thanks for this.

just one question though.
right now if i have 2 pages then i will need to add below code.
how can i change it to do the numbering for all pages without looping?

pdfDocument.Pages(1).AddStamp(pageNumberStamp)
pdfDocument.Pages(2).AddStamp(pageNumberStamp)

Hi there,


Thanks for your inquiry. Please check following code snippet to add stamp to all pages of a PDF document. Hopefully it will serve the purpose.

//open document
Document pdfDocument = new Document(“input.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 = 10;
pageNumberStamp.HorizontalAlignment = HorizontalAlignment.Center;
pageNumberStamp.StartingNumber = 1;
//set text properties
pageNumberStamp.TextState.Font = FontRepository.FindFont(“Arial”);
pageNumberStamp.TextState.FontSize = 14.0F;
pageNumberStamp.TextState.FontStyle = FontStyles.Bold;
pageNumberStamp.TextState.FontStyle = FontStyles.Italic;
pageNumberStamp.TextState.ForegroundColor = Color.Aqua;

foreach (Page page in pdfDocument.Pages)
{
//add stamp to all pages
pdfDocument.Pages[page.Number].AddStamp(pageNumberStamp);
}
//save output document
pdfDocument.Save(“output.pdf”);

Please feel free to contact us for any further assistance.

Best Regards,