Free Support Forum -

Not taking both footer and Page number setting at a time


I'm using the Apose for adding the footer and page numbers in PDF. Version is JDK. Aspose jar is : aspose.pdf.kit_3.2.0_20100726.jar

I'm using the following code for adding the footer text and page numbers. Both are not printing.

fileStamp = new PdfFileStamp("d:\\test.pdf", "d:\\stamped_test.pdf");
FormattedText footerText_format = new FormattedText("Footer", new FontColor(0, 10, 170), FontStyle.TimesRoman, EncodingType.Winansi, false, 10);
fileStamp.addFooter(footerText_format, 80);

fileStamp.addPageNumber("Page #");


Regards ,


Hi Dheeraj,

Please add header and page number separately; that is, first add header and save the output and then add page number in the first output file.

I hope this helps. If you still find any issue or have more questions, please do let us know.

Hi Shahzad,

Thanks for quick repose.

After implementing as per you suggestions, both footer text and pager numbers are stamping correctly in the pdf file. I need to display the pagenumbers X of Y ( Total pages in PDF file).Currently it is displaying only current page numbet. How to implement the above requirement.


fileStamp = new PdfFileStamp(infile, outfile);
FormattedText ft = new FormattedText("Page # ", new FontColor(0, 0, 100), FontStyle.CourierBold, EncodingType.Winansi, false, new Integer(pageNumberSize));
fileStamp.addPageNumber(ft, 1);



Hi Dheeraj,

In order to fulfill your requirement, you first need to get the total number of pages of the PDF file using NumberOfPages property of the PdfFileInfo class. Later, you can concatenate this total with the Page # string i.e. FormattedText(“Page # of” + totalPages).

I hope you understand. If you need any further assistance, please do let us know.