简体   繁体   中英

Itext PDFReader reading 256-bit AES encrypted pdf

I am receiving an error when trying to open a pdf file to read its contents and map data back into the pdf. The error is: com.itextpdf.text.exceptions.InvalidPdfException: Unknown encryption type R = 6 at com.itextpdf.text.pdf.PdfReader.readPdf(PdfReader.java:631)

I am using java 1.6, Itext 5.4.1, and bouncycastle 1.48 . The pdf was created as version 1.7, and encrypted as 256-bit AES. Does anyone have an example in Java for reading this type of ecncrypted pdf.

Currently my code reads all pdf previous versions without any errors, the previous versions are encrypted at 128 bit encryption.

        PdfReader reader = new PdfReader(src,"passwordtext".getBytes());
        PdfStamper stamper = new PdfStamper(reader, new FileOutputStream(dest));
        AcroFields form = stamper.getAcroFields(); 

Any help is appreciated.

Revision 6 is included in 'ISO 32000-2' which is PDF 2.0. Since PDF 2.0 is not yet an official standard iText does not support it. Now you can ask yourself how and why do you already have a document using that standard? Adobe already implemented it even though it is not publicly available and not yet released (and thus due to change) which is a bad decision on their part. After the standard has been released iText will also support it but you'll have to wait for that. Until then regenerate that document with Adobe Acrobat using a "lower" encryption algorithm (eg revision 1-5).

Update in 2021: The standard has been released in 2017, so Revision 6 is good to go.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM