Low performance in document.save() in Aspose.pdf in .NET Core

I have been recently working on building a PDF Server to convert text files into PDF files with your product “Aspsose.pdf”. What I need to do is not just simple conversion but read every characters for cutomized fontstyles. Because of the demand to process a large amount of files in a limited time, I had tried many different methods to optimize the performance.

These are the methods I had used (Please inform me if I did anything wrong):

  1. Instead of reading each character as a TextSegment, I read several words as a TextFragment by some self-defined delimiters. I thought reducing the number of the components I used would eventually speed up a little.
  2. I found the OptimizeResources function was quite time-consuming, so I took away it. (Indeed it worked)

Here is a table I made to compare performances:
PerformanceComparison.png (13.3 KB)

I found that the most time-consuming part is the document.save() function. For example: a file with 89 pages took 7.7 sec to finish, whereas document.save() occupied 3/4 of the total spent time. Is it because the whole document was held in memory, and didn’t write to file until document.save()? In iTextSharp, it uses stream to write files directly. Is there any method like that?

Is there any chance I can make the performance as good as iTextSharp does or at least not differ too much?

Thank you very much!

@Eric860723

This scenario needs further and detailed investigation. If possible, can you please share a sample console application with all of your code routine and sample document? It would help us in investigating the issue and address it accordingly.

@asad.ali
Hi,asad
Thank you for your reply.
Here is our source code and sample documents.
ModifiedTransPdfForForum.zip (4.2 MB)

All the pdf-related logic will be in the C_PDF function.

@Eric860723

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): PDFNET-55560

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

1 Like