javiergutierrezchamorro / nikkhokkho

Software Javier Gutiérrez Chamorro (Guti)
http://nikkhokkho.sourceforge.net/
7 stars 4 forks source link

RFE: Optionally add support to decrypt PDFs (& related) before processing #12

Closed TPS closed 8 years ago

TPS commented 8 years ago

@javiergutierrezchamorro Another way to handle the recent PDF handling updates would be to optionally decrypt PDFs before optimizing, using, e.g., qpdf --decrypt. Binaries are @ https://sourceforge.net/projects/qpdf/files/qpdf/; most recent source may be @ https://github.com/qpdf/qpdf.

N.B.: The above docs mention the need for a password to decrypt. I've found that qpdf can handle many kinds of "encrypted" PDFs (e.g., those with "edit" passwords, but no "open" passwords) without supplying such! GhostScript often barfs at these, but not after processing with qpdf. YMMV.…

TPS commented 8 years ago

pdfclean (part of mupdf tools) will reportedly also do this decrypt with same kinds of PDFs while doing garbage collection via -ggg.

javiergutierrezchamorro commented 8 years ago

Will think about it. Problem is it will require a per file password to be stored somewhere, which will require lots of changes.

Do not like the idea of prompting the user interactively, since it will prevent automation via command line. So maybe the solution is a setting to ask or not for passwords.

javiergutierrezchamorro commented 8 years ago

As for pdfclean, I guess this is already done by ghoscript and smpdf. Have you performed any tests with it?

TPS commented 8 years ago

Do not like the idea of prompting the user interactively, since it will prevent automation via command line.

I meant this only for PDFs which don't need interactive processing, where the edit-password/DRM can be removed auto-magically.

TPS commented 8 years ago

Have you performed any tests with it?

Yes, running pdfclean -ggg usually will inflate an already-FileOptimized PDF, but then re-running FileOptimizer will generally shrink it further than before pdfclean.

Made ToDo via https://github.com/svn2github/nikkhokkho/commit/f892b80b14fc19e214e5af0a41fc5f7a2df40abc! ☺ 🎉

javiergutierrezchamorro commented 8 years ago

Did additional tests, and using pdfclean -ggg -z before Ghostcript and smpdf, seems to get better ratios, so it is now added in r567 (https://sourceforge.net/p/nikkhokkho/code/567/).

TPS commented 8 years ago

Thanks, @javiergutierrezchamorro!

Here, it's https://github.com/svn2github/nikkhokkho/commit/53d03ec4b48dfb9240c3ff2719857cb501d184eb.