- Home
- Forum
- ASP.NET Core - EJ 2
- When generating a PDF, use a FileStream and periodically flush memory contents to disk
When generating a PDF, use a FileStream and periodically flush memory contents to disk
Hello,
I'm using the PDF library to generate documents. I have a requirement where I have to generate a PDF document listing all of a customer's data in tabular form. That means I need to generate a PDF with a PdfGrid containing up to 20,000,000 rows. Even generating a document with a PdfGrid containing 100,000 rows takes almost 10 minutes.
The PDF library (via PdfDocument) appears to create the entire document in memory, and only then allows saving it to disk when the document is fully created.
Is it possible to use a FileStream as the underlying stream and periodically flush the document to disk while it is being generated? Like, after I add 10,000 rows to the PdfGrid, can I flush the current memory contents to disk?
Are there other ways to reduce the amount of memory used when generating large PDFs?
Thank you,
Jon
Thank you for the response.
I have a reproduction of the issue here:
https://github.com/jonsagara/SyncfusionGenerateLargePdf
Is it possible for you to take a look at it and make recommendations to increase performance?
Great. Thank you.
Hi Gowthamraj,
Thank you for the time and effort you have put into coming up with a solution. Unfortunately, having breaks in the middle of the document where they were merged together doesn't work for us. We need the grid to be contiguous. It's unfortunate because the library works perfectly for all of our other use cases.
Is there a chance that you'll be able to improve the performance of the library to make my original code work?
Thanks,
Jon
Thank you for your update.
No. It is not possible to improve the performance by disposing the underlying objects while rendering the grid. At per current architecture, when creating a PDF Grid with large number of rows, it will take the responsible amount of time to complete the whole grid rendering process, we could not flush the document to disk.
- 8 Replies
- 3 Participants
-
JS Jon Sagara
- Nov 23, 2021 06:48 PM UTC
- Dec 2, 2021 12:56 PM UTC