Closed niazangels closed 5 years ago
@niazangels Thanks for pointing it out! Please raise that pull request :)
Done! Could you please review https://github.com/socialcopsdev/camelot/pull/311 ?
Thanks for the PR, I'll do it this weekend!
Closing in favor of https://github.com/camelot-dev/camelot/issues/21.
camelot.handler._save_page
is called as many times as there arepages
passed tocamelot.read_pdf
. Each time this function is invoked, the source PDF is read from disk, parsed usingPdfFileReader
and is decrypted. This is something which can be reduced that contributes significantly to performance.A great way to avoid this is accept a list of
pages
instead ofpage
and run_save_pages
function only once. ThePdfFileReader
object can be created once and we can loop overpages
to save the pages separately.I have this already working on a private fork with one hiccup that the
PdfFileReader
object gets modified for certain files after successfully looping and extracting ~80 pages in some of my sample PDFs. I create a copy of the original object to work around this but its a whole lot faster than the current approach as it completely avoids the 80+ file reads.Let me know if this is something you'd like to incorporate, and I'd be happy to raise a pull request.
Cheers, and thanks for all the great work! :smile: