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

Free Support Forum - aspose.com

Find and Replace text inside PDF using Aspose.PDF for .NET - Speed Up Find/Replace Operation

I am using Apose.PDF to find and replace text in a PDF document. The document can have some 2000 pages and the operation is taking more than 5 seconds. I am using:
Dim textFragmentAbsorber As Aspose.Pdf.Text.TextFragmentAbsorber = New Aspose.Pdf.Text.TextFragmentAbsorber(find)

Is there a faster way to do this to reduce the search time? Is there a way to tell the search to limit it to just the bottom of the document perhaps?


You can search the text in document at page level in order to reduce the time cost. The code modifications would be as follows:

foreach (Page page in doc.Pages)
 TextFragmentAbsorber finder = new TextFragmentAbsorber(keyword);
 // Further stuff

Furthermore, you can also specify a particular region in PDF Page where text should be looked for. Please follow the instructions give in following article and in case you face any issue, please let us know by sharing a sample PDF document.

Thanks, I tried that and the there isn’t much of a speed gain. Whats the recommended method of doing this on multiple threads? For example could I use

Parallel.ForEach(pdf.Pages, (page) => page.Accept…)

Or could I put each page search in a task. When I have tried the above, I get errors around modifying the fragment collection


As per recommended practice, only one thread should be allocated to one PDF document at a time. However, would you kindly share your sample PDF document along with complete code snippet. We will test the scenario in our environment and address it accordingly.

We have decided to take another route for this problem. I will be in touch if I need further help.


Sure, please let us know in case you need further assistance.