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

Free Support Forum - aspose.com

PageNumberStamp

Dear support,

I have two documents:

Document #1: 10 pages with page stamp (pages 1 thru 10).
Document #2: 5 pages with page stamp (pages 1 thru 5).

When I merge the two, I end up with two page stamps. In other words, page 11 has two stamps overlapping each other (I attached a screen shot):
Page stamp from the original
+ Page stamp from the new document

Is there a way to remove pagenumberstamps prior to merging?
Or a way to update an existing stamp?

Hi There,


Thanks for contacting support.

When I merge the two, I end up with two page stamps. In other words, page 11 has two stamps overlapping each other (I attached a screen shot):

p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px 'Helvetica Neue'; -webkit-text-stroke: #000000} span.s1 {font-kerning: none}

I will appreciate if you please share your sample code along with input files. It will help us to understand your requirement exactly and address it accordingly.


Is there a way to remove pagenumberstamps prior to merging?

Yes, you can remove pageNumberStamps prior to merging. Please check below sample code snippets for removing the pageNumberStamps from the PDF document.

C#
Aspose.Pdf.Facades.PdfContentEditor contentEditor = new Aspose.Pdf.Facades.PdfContentEditor();
contentEditor.BindPdf(dataDir + "AddPageNumbers.pdf");
//Get all stamps in the document
Aspose.Pdf.Facades.StampInfo[] stampInfo = contentEditor.GetStamps(1);
contentEditor.DeleteStampByIds(new int[] { 999 });
//save file
contentEditor.Save(dataDir + "testout.pdf");

After removing Stamps from both PDF documents you can merge and create a new Stamp with the help of following code snippet.

C#
// Create PdfFileStamp object
PdfFileStamp fileStamp = new PdfFileStamp();
// Open Document
fileStamp.BindPdf(dataDir + "concatenatedfile.pdf");
// Get total number of pages
int totalPages = new PdfFileInfo(dataDir + "concatenatedfile.pdf").NumberOfPages;
// Create formatted text for page number
FormattedText formattedText = new FormattedText("Page # Of " + totalPages, System.Drawing.Color.Blue, System.Drawing.Color.Gray, Aspose.Pdf.Facades.FontStyle.Courier, EncodingType.Winansi, false, 14);
// Please note you must add StampId, so you can remove it by StampId
fileStamp.StampId = 999;
// Set starting number for first page; you might want to start from 2 or more
fileStamp.StartingNumber = 1;
// Add page number
fileStamp.AddPageNumber(formattedText, 0);
// Save updated PDF file
fileStamp.Save(dataDir + "AddPageNumber_out12.pdf");
// Close fileStamp
fileStamp.Close();

If you still face any issue, please feel free to contact us.

Best Regards,

Assigning the stampid did the trick and the problem is now fixed.

Thank you.
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px 'Helvetica Neue'; -webkit-text-stroke: #000000} p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px 'Helvetica Neue'; -webkit-text-stroke: #000000; min-height: 14.0px} span.s1 {font-kerning: none}

Hi there,


Thanks for your feedback. It is good to know that suggested code worked for you.


Please keep using our API and feel free to contact us for any question or concern, we will be more than happy to extend our support.


Best Regards,