barryvdh / laravel-dompdf

A DOMPDF Wrapper for Laravel
MIT License
6.62k stars 965 forks source link

Large data export (about 1500 pages) #961

Closed asifanamkhan closed 1 year ago

asifanamkhan commented 1 year ago

I'm writing code for export report with large data about (20k + rows); It takes too much time to render the report. sometimes it takes 30 min to render. what is the solution for fast rendering.

voxsar commented 1 year ago

if you have multiple threads, run them as background threads to make multiple pdfs, if you are using laravel you can use schedule jobs (make sure there not on the main thread), select page ranges for each thread.

Thread 1: Pages 1 to 10 Thread 2: Pages 11 to 20 etc

Then merge the pdfs once they are all done, I dont think this dom pdf has the service to merge so use a different lib for merging or an online api for that

Send a notification to the user that this pdf is large therefore it will take time, and they will get an email when it is ready to be viewed

I made enough assumptions about your use case to file divorce lol

voxsar commented 1 year ago

Check this library: https://packagist.org/packages/iio/libmergepdf for merging

asifanamkhan commented 1 year ago

Thank you so much. I found a alternative solution (Laravel snappy) for large data export and it works good.