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

Free Support Forum - aspose.com

doc.Pages.Accept is pretty slow while attaching TextFragmentAbsorber

Hello,

I have a piece of code that does the following.

                TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber(searchText);
                pdfDocument.Pages.Accept(textFragmentAbsorber); // Taking good 3-4 seconds

When I try to add the “textFragmentAbsorber” to the pdfDocument object, it’s taking good 3 seconds or more. Is there a better and faster way to handle this to improve performance? After doing some load testing, it seems to cause memory leaks and crashing the server.

Also, this runs pretty quick on my local machine (Mac OS), however it’s taking 3-4 seconds on an Ubuntu Server (EC2 instance). The PDF contains 18 pages.

Thank you
Harish

@harishupad

You can split the Accept() call at page level as following to make the processing faster:

foreach(Page page in pdfDocument.Pages)
{
 TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber(searchText);
 page.Accept(textFragmentAbsorber);
 // Do some stuff
 page.Dispose();
}

In case issue still persists, please share your sample PDF document with us. We will test the scenario in our environment and address it accordingly.

Thank you @asad.ali, I will make this change and monitor, I will let you know if I see any problems with this.

@harishupad

Sure, please take your time while testing our suggestions and let us know about your feedback.