We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Pdf creation slows down significantly every time a new one is created

In my app, I am drawing a new PDF and filling it with data every time a user needs to fill out a new form. This works perfectly fine, however the PDF creation slows down significantly each time it is drawn even though it is done from scratch. This is an issue for me as my PDF's are much larger than the one shown in my example, and has many more fields.


I have created a sample project here to demonstrate my issue: https://github.com/isenbj/Syncfusion_slow_pdf_creation/blob/master/lib/main.dart

Simply click the button in the bottom right to see.

Initial drawing of the PDF takes .13 seconds to draw.
https://prnt.sc/HDfIwqsvDOie

After 16 drawings the pdf takes 1.1 seconds to draw to draw a single pdf .
https://prnt.sc/bLdWVMJGt9oX


After 23 draws, the pdf takes 2.77 seconds to draw a single pdf.
https://prnt.sc/ZiMFrWCOQM2L


Since the PDF is created from scratch each time, there should be little to no variance in time. However, it slows down significantly each time. It can take a minute or longer eventually, where as the first time is near instantaneous.


2 Replies

IJ Irfana Jaffer Sadhik Syncfusion Team January 11, 2023 04:56 AM UTC

On analysis, we found that the performance issue occurs since the PdfDocument instance is not disposed after being created multiple times. To resolve this performance lack, kindly dispose the Pdf document instance after saving the pdf as bytes.

Kindly refer the following code snippet for reference,

//Saves the document.

List<int> pdfBytes = await document.save();

 

//Disposes the document.

document.dispose();

 

We have also included dispose in the provided code sample for reference, https://www.syncfusion.com/downloads/support/directtrac/general/ze/Syncfusion_slow_pdf_creation-master-4293217

 

 Please refer to the attachment for more details.


Attachment: Attachment_4deb40f6.rar


JI Jeremy Isenburg replied to Irfana Jaffer Sadhik January 13, 2023 04:17 AM UTC

Thank you, this solved my issue.


Loader.
Live Chat Icon For mobile
Up arrow icon