-
Notifications
You must be signed in to change notification settings - Fork 85
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
A much faster mergePage function #27
Comments
I am new to GitHub and don't know the best way to propose my version on this site. Thanks for any advice. |
I posted all the code in the Averell7 fork. Since it is fully compatible with the present code, let us hope one day it will be integrated in pyPdf. |
will this patch get mainlined? |
Hi I have tried this patch. Indeed, the merging step is much better than before. But... i have the impression that the time of the saving file step has increased more (x10) than the merging step has decreased (/3). Thank you |
Hi vnakk, Source file : full text, 520 pages A4, output : booklet, A3, 260 pages
Mergepage3 (Fast mode) :
With a more sophisticated page, graphics and so on, the gain is 10x for creating Pdf, 2x for saving. Note that PdfBooklet is in beta state and does not work with all pfd files in slow mode. |
mergePage function is slow. Needing more speed, I have written a modified version mergePage3 which is much faster when you merge pages from the same file (up to 200x faster) and faster also when you merge pages from different files. I can share the code if you are interested.
The basic idea : mergePage uses StreamContent to get the content of a page. But this class always starts the parseContentStream function even when this is not needed, and this function is time consuming.
mergePage3 parses the content only when really needed. Result is :
On a test file of 55 pages, if I put two pages on a sheet (booklet), with mergePage, it takes 34 seconds, with mergePage3 it takes 0.4 second. (I consider here only the time needed for mergePage, not the generation of the output file.
If you are interested, I can share the code.
The text was updated successfully, but these errors were encountered: