szcf-weiya / techNotes

My notes about technology.
https://tech.hohoweiya.xyz/
11 stars 7 forks source link

pdftk failed on ID990A.pdf #45

Open szcf-weiya opened 1 year ago

szcf-weiya commented 1 year ago

I want to extract the 8th page of ID990A.pdf, but it throws the following error,

$ pdftk ID990A.pdf cat 8 output ID990A_8.pdf 
Error: Unexpected Exception in open_reader()
pdftk.com.lowagie.text.exceptions.InvalidPdfException: unknown.encryption.type.r
    at pdftk.com.lowagie.text.pdf.PdfReader.readPdf(PdfReader.java:514)
    at pdftk.com.lowagie.text.pdf.PdfReader.<init>(PdfReader.java:172)
    at pdftk.com.lowagie.text.pdf.PdfReader.<init>(PdfReader.java:161)
    at com.gitlab.pdftk_java.TK_Session.add_reader(TK_Session.java:126)
    at com.gitlab.pdftk_java.TK_Session.add_reader(TK_Session.java:229)
    at com.gitlab.pdftk_java.TK_Session.open_input_pdf_readers(TK_Session.java:242)
    at com.gitlab.pdftk_java.TK_Session.<init>(TK_Session.java:869)
    at com.gitlab.pdftk_java.pdftk.main_noexit(pdftk.java:150)
    at com.gitlab.pdftk_java.pdftk.main(pdftk.java:128)
Error: Failed to open PDF file: 
   ID990A.pdf
Errors encountered.  No output created.
Done.  Input errors, so no output created.

To avoid the possible snap error that on external disk, I also tried to mv the pdf to ~/Download folder, but still not work.

Also check that pdftk works fine on other pdf documents.

So the potential reason might be the interactive fields in ID990A.pdf

Later, I print the 8th page to another file to get the 8th page.