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

Free Support Forum - aspose.com

ReplaceText only replacing some instances within pdf

I'm currently using the trial version of Aspose.Pdf for .NET (version 6.9). I've created a text only pdf document (attached). When i run the following code only some instances of the search text get replaced, most are ignored.

pdfContentEditor pdfContentEditor = new PdfContentEditor();
pdfContentEditor.ReplaceText("Lorem Ipsum", "LOREMxIPSUM");

I've included an amended version to show the results (in which you'll see some other rendering issues). I'm using the .Net 2.0 version of the dll.

I've tried other ways too, but get the same results. Is this a 'feature' of the trial version?

What I'm trying to do is take a pre-populated pdf as a template, so we can replace various tags with data at run time. While this may not be the correct way I would expect it to work.

Any help would be appreciated.

Hi Phil,

Thanks for using our products and sharing the sample source code and template PDF documents with us.

I tested the scenario and able to notice the same problem. For rectification, I logged this problem with ID: PDFNEWNET-33564 in our Issue Tracking System. We will further look into the details of this issue and will keep you updated via this forum thread on the status of correction.

We apologize for your inconvenience.

Thanks & Regards,

I think it's because I was using the demo version. I've subsequently got a 30 day temp license and it now appears to work with one exception which is where the text is split by a line break, but that's not unreasonable. As for the other display artifacts, they remain.

So there's clearly an issue with running in un-licensed mode which may be putting people off using the product!

Hi Phil,

Thanks for your feedback.

I have tested the scenario with your provided sample source code using Aspose.Pdf for .NET v6.9 (Licensed Version) and the environment where I was testing: Windows 7 x32, Visual Studio 2010 and .NET Framework v2.0. During my testing, I was facing the same issue as you mentioned before. That's why I was logged this issue in our issue tracking system.

We would appreciate, if you create a sample application and post here to show the new issue you are facing. Moreover, this issue might be related to environment, please share some details regarding your environment i.e. Operating System, OS Architecture, .NET Framework version, VisualStudio version etc. This will help us to identify the issue and reply back to you soon.We are really sorry for this inconvenience.

Thanks & Regards,

I'm running the following


The runtime version of Aspose.pdf appears to be the v1.1.4322 one, but i'm running the rest of the application at v2.0.50727. Not sure why app keeps defaulting to the 1.1 version as I start out selecting the v2.0 one.

Using MS Visual Studio 2005 on Win XP

It id definately fixed by including the following:-

Aspose.Pdf.License license = new Aspose.Pdf.License();


Hi Phil,

Thanks for sharing the details.

Adding more to Rashid’s comments, I have tested the scenario while using Aspose.Pdf for .NET 6.9.0 in Visual Studio 2005 project running over Windows XP-SP3 and as per my observations, the text replace feature is having some issues and only first occurrence of Lorem Ipsum string is being replaced. I have tested the scenario in both License mode as well as in Trial mode. We will further look into the details of this problem and will keep you updated on the status of correction.

However as a workaround, please try using the new Document Object Model approach of new Merged API and as per my observations, all the instances of Lorem Ipsum are being replaced inside the PDF document. Nevertheless, there are some other issues i.e. some characters are being overlapped in the same string where Lorem Ipsum word is being replaced. We will definitely consider this issue during the resolution of this problem. Please be patient and spare us little time. We are really sorry for this inconvenience.

For your reference, I have attached the resultant PDF that I have generated using new DOM API approach.

The issues you have found earlier (filed as PDFNEWNET-33564) have been fixed in Aspose.Pdf for .NET 9.8.0.

This message was posted using Notification2Forum from Downloads module by Aspose Notifier.