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

Free Support Forum - aspose.com

How to replace string placeholder in Aspose Pdf

Hi!

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);

sec1.Paragraphs.Add(txtTblHeader);

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

pdf1.Save(finalStream);

byte[] downloadBytes = finalStream.ToArray();

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

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

HttpContext.Current.Response.BinaryWrite(downloadBytes);

HttpContext.Current.Response.End();

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.