Free Support Forum -

[JAVA] Display the page numbers in a footer


I would like to display the page numbers in the PDF files I generate with aspose.pdf for Java

I found many examples on how to do it in this forum but only with C#.

I adapted the code i found in theses examples for Java, but the result i got is a footer that displays $p.

It seems that this symbol $p used in C# is not recognized in Java.

Here is my code :

Pdf pdf = new Pdf();

Section sec1 = pdf.getSections().add();

HeaderFooter header1 = new HeaderFooter(sec1);



header1.getParagraphs().add(new Text(sec1,"page $p"));

Text text1 = new Text(sec1,getFileContent());

sec1.getParagraphs().add(text1); FileOutputStream(new File("HelloWorldExample3.pdf")));

Can anybody help me, please?



I have tested your code and was able to reproduce the error. I have logged this as PDFJAVA-4402 in our issue tracking system. We will try our best to resolve this issue as soon as possible.



thank you for your answer.


This feature is not supported in the current version. We have planed to publish a new version late this month or early next month. We will support this feature in the new version. If you are urgent we can provide beta version to you before the new release.