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

Free Support Forum - aspose.com

Using a hash (#) in a page number stamp

Howdy,

We have a use case to use a # character in a PDF page stamp. Unfortunately, we also need this stamp to keep track of page numbering, and Aspose’s PdfFileStamp and PageNumberStamp objects currently use the # character as a replacement token for page numbering.

Is there any way to escape # characters when adding page numbers so that they aren’t replaced? Or is there another way to add page numbers that use a different replacement token?

Thanks in advance!

@jpf

You can use $ instead of hash (#) to implement page numbers like in following code snippet:

Document doc = new Document();
doc.Pages.Add();
doc.Pages.Add();
doc.Pages[1].Paragraphs.Add(new TextFragment("Page $p of $P"));
doc.Pages[2].Paragraphs.Add(new TextFragment("Page $p of $P"));
doc.Save(dataDir + "PageNumbers.pdf");

In case you need further assistance, please feel free to let us know.