-
-
Notifications
You must be signed in to change notification settings - Fork 686
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Perfomance on large pdf #545
Comments
WeasyPrint is known to be slow. The only general advice I can give you is to use Python 3.6 and the latest version of WeasyPrint. If you can share your HTML source, I can try to find why your document takes an especially long time to get rendered. |
@liZe this is the page http://www.placesrank.it/pdf-destination?place=6290&campaign=8 |
@alecasciaro Thank you for this example. It takes about 2:20 minutes for me, with:
There's a big performance problem about the fixed boxes or page margins. I'll try to find where it comes from. |
Ok thank you @liZe, i realy appreciate it |
@liZe Is there any advance on this issue? I'd like to know if there's something in particular to look at to help improve this |
OK, I've found the source of the problem. More than half of the time is taken by downloading photos. A solution to avoid that is to render PDFs on the same server than your website, and use something that gets the resources on disk rather than through network. That's what Flask-WeasyPrint or Django-WeasyPrint do for example, you can take a look on how they work and duplicate the behaviour for your own use. |
@liZe Just a question do WeasyPrint download the images in parallel or serially? |
@liZe , i tried to remove all image and all css but performance increase only 20 seconds. Thanks for your time. |
They're downloaded serially. I would be better to have parallel download, but that would not be as interesting as in a browser: layout is only done once in WeasyPrint and depends on image sizes, when it's done again and again in a browser while images are still downloading. I can't find any simple solution right now, but we may find a smart way to asynchronously download images when creating the boxes and wait for them if they're not downloaded yet during the layout. If you're interested, that's a cool new issue to open 😉! |
Sorry, I forgot this comment. With only Other bugs have been reported with performance problems (see #553 or #483 for example), but these issues were focused on special cases that were outstandingly slow. Your case just shows that WeasyPrint is generally slow 😢, there's unfortunately no magic wand to fix your problem. I try hard to improve performance and memory use on a regular basis (see #384 and #70 for example), but it's an endless, very frustrating work. I can sometimes spend days getting a 5% speed improvement … or often nothing. I'm open to suggestions (and parallel download of resources is a good one), but I didn't find another specific point of failure I can work on for your document. |
Hi @liZe it's been a while 😄 I am interested in learning the best practices when designing you HTML/CSS template and using WeasyPrint, in order to get the fastest result possible. Are there written guidelines or can you list few points? Thanks! |
@liZe As you know, In Python world, often speedup involves writing part of code in Cython. Eventhough it is tedious at first, it will not affect the users installing |
Hi,
i'm trying to convert an html page that generate a 52 pages pdf.
Weasyprint needs 1.40 minute to create the the 52 page pdf.
I looked for a solution, removing image and all css (thinking that maybe some css convertion could be slow) but performance increase only 20 seconds.
Someone can give me some advice to improve the performance?
Thanks
The text was updated successfully, but these errors were encountered: