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

Free Support Forum - aspose.com

AddpageNumber overwrites AddHeader

I have some code that merges 3 PDFs together and then attempts to write out a Page Header, Page Footer and Page Number in the lower right.

If I exclude the AddPageNumber code then the header and footer show up. if I include the AddPageNumber code then the header and footer dont show up.

Any ideas?

(Note, I've tried a number of different variations for position on AddHeader and AddFooter. )

Here's the code:

PdfFileStamp fileStamp = new PdfFileStamp(PathFromJoined, @"C:\test.pdf");
FormattedText headerText = new FormattedText("Header Text");
FormattedText footerText = new FormattedText("Footer Text");
fileStamp.AddHeader(headerText, 5, 5,0);
fileStamp.AddFooter(footerText, 30, 50, 0);

FormattedText pageNumber = new FormattedText("Page #");
fileStamp.AddPageNumber(pageNumber, 1);
fileStamp.Close(); PdfFileStamp fileStamp = new PdfFileStamp(PathFromJoined, @"C:\test.pdf");
FormattedText headerText = new FormattedText("Header Text");
FormattedText footerText = new FormattedText("Footer Text");
fileStamp.AddHeader(headerText, 5, 5,0);
fileStamp.AddFooter(footerText, 30, 50, 0);

FormattedText pageNumber = new FormattedText("Page #");
fileStamp.AddPageNumber(pageNumber, 1);
fileStamp.Close();

Hi David,


Thanks for using our products and sorry for replying you late. Can you please share the Merged PDF document over which you are trying to add Header/Footer, so that we can test the scenario at our end. We apologize for your inconvenience.

Actually the day before you posted I found the solution in another post.What I'm doing now is using the code I found elsewhere, using the stamp:

......

for (int i = 1; i <= count; i++)
{
Stamp newStampHeaderText = new Stamp();
newStampHeaderText.BindLogo(headerText);
newStampHeaderText.Pages = new int[] { i };
newStampHeaderText.SetOrigin(fileInfo.GetPageWidth(i)-30, fileInfo.GetPageHeight(i) - 10 - 50); for (int i = 1; i <= count; i++)
.....

And this is working where the other code samples weren't which is great.

Hi David,


Thanks for contacting support. I am glad to hear that your problem is fixed. In case you need any further assistance, please feel free to contact.