Free Support Forum -

Replace Text in All Pages of PDF


I would like to replace text in all pages of PDF. I was looking at your example

Aspose.Pdf > Programming Guide > Working with Text > Replace Text in All Pages of PDF

Document pdfDocument = new Document(“Sample2.pdf”);

TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber("@TravelerName@");


TextFragmentCollection textFragmentCollection = textFragmentAbsorber.TextFragments;

foreach (TextFragment textFragment in textFragmentCollection)


textFragment.Text = “Bart Simpson”;



While it removes the text, it also wipes out some other text and adds some added question marks. Please help.



Hi Alfred,

Thanks for contacting support.

I have tested the scenario using Aspose.Pdf for .NET 9.0.0 and as per my observations, when using the API in trial mode, questions marks are added in resultant file and also some text other than @TravelerName@ is being replaced inside PDF file. However when using a valid license, these issues do not appear. See attached output generated over my end.

But during my testing, I have noticed that not all instances of @TravelerName@ are being replaced. For the sake of correction, I have logged this problem
as PDFNEWNET-36518 in our issue tracking system. We will further
look into the details of this problem and will keep you updated on the status
of correction. Please be patient and spare us little time. We are sorry for
this inconvenience.

The issues you have found earlier (filed as PDFNET-36518) have been fixed in Aspose.PDF for .NET 18.5. This message was posted using BugNotificationTool by asad.ali