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

Free Support Forum - aspose.com

How to replace string placeholder in Aspose Pdf


I need to replace the page number dynamically in the sting that I am using. Please advise.

string documentTitle = "testPDF";

Aspose.Pdf.Generator.Pdf pdf1 = new Aspose.Pdf.Generator.Pdf();

Aspose.Pdf.Generator.Section sec1 = pdf1.Sections.Add();

var txtPage = new Aspose.Pdf.Generator.Text("Page: $p");

string strPageNumber = string.Format("Your page number is {0} ", txtPage);

Aspose.Pdf.Generator.Text txtTblHeader = new Text(strPageNumber);


System.IO.MemoryStream finalStream = new System.IO.MemoryStream();


byte[] downloadBytes = finalStream.ToArray();

HttpContext.Current.Response.AddHeader("Content-Type", "application/pdf");

HttpContext.Current.Response.AddHeader("Content-Disposition", "inline; filename=" + documentTitle + ".pdf");



Hi Lakshmi,

Thanks for contacting support.

Please append blank space at the end $p so that current page number is displayed in PDF file. The information is also specified over [this link](http://www.aspose.com/docs/display/pdfnet/Others).

In case you still face the same problem or you have any further query, please feel free to contact. We apologize for your inconvenience.