Hi,
I am using PDFbox to test whether a password is correct for a protected
PDF before handling it with a different process. This is working for the
vast majority of files I receive but from one particular source PDFbox
reports an invalid password when the files can be opened without
complaint in GUI applications (Adobe Reader et. al.).
These files are created by scanning to PDF on Xerox MFDs and using the
MFD's menus to add a password to the document. As luck would have it I
have access to the same MFDs in my location and my files created using
the same method are correctly read by PDFbox.
The issue can be seen using the command line utilities and the same is
seen on v2.0.29 and v3.0.0-beta1 (I am using the 2.0 series in the
application):
❯ java -jar pdfbox-app-2.0.29.jar Decrypt -password JUL2023rfi
invalid_password.pdf
Exception in thread "main"
org.apache.pdfbox.pdmodel.encryption.InvalidPasswordException: Cannot
decrypt PDF, the password is incorrect
at
org.apache.pdfbox.pdmodel.encryption.StandardSecurityHandler.prepareForDecryption(StandardSecurityHandler.java:284)
at
org.apache.pdfbox.pdfparser.COSParser.prepareDecryption(COSParser.java:2992)
at
org.apache.pdfbox.pdfparser.COSParser.retrieveTrailer(COSParser.java:285)
at
org.apache.pdfbox.pdfparser.PDFParser.initialParse(PDFParser.java:173)
at
org.apache.pdfbox.pdfparser.PDFParser.parse(PDFParser.java:226)
at
org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1110)
at
org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1093)
at
org.apache.pdfbox.pdmodel.PDDocument.load(PDDocument.java:1070)
at org.apache.pdfbox.tools.Decrypt.decrypt(Decrypt.java:143)
at org.apache.pdfbox.tools.Decrypt.main(Decrypt.java:65)
at org.apache.pdfbox.tools.PDFBox.main(PDFBox.java:52)
❯ java -jar pdfbox-app-3.0.0-beta1.jar Decrypt -password JUL2023rfi -i
invalid_password.pdf
Error decrypting document [InvalidPasswordException]: Cannot decrypt
PDF, the password is incorrect
I have uploaded a sample file (a scan of two blank A4 pages) to
https://filebin.net/eaipt8ujf7rmp6eq (expires in 6 days) - the sha256sum
is
68d0cc20c10174caf51b92624e042db7d463920e21f0b4a23c170b5901a63b20
invalid_password.pdf
Any help is appreciated and I'd be happy to create a Jira issue if
someone can approve my account creation request.
Steve Davies
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@pdfbox.apache.org
For additional commands, e-mail: users-h...@pdfbox.apache.org