简体   繁体   English

itext PDFReader 阅读 256 位 AES 加密的 pdf

[英]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.我在尝试打开 pdf 文件以读取其内容并将数据映射回 pdf 时收到错误。 The error is: com.itextpdf.text.exceptions.InvalidPdfException: Unknown encryption type R = 6 at com.itextpdf.text.pdf.PdfReader.readPdf(PdfReader.java:631)错误是: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 .我使用的是 java 1.6、Itext 5.4.1 和 bouncycastle 1.48。 The pdf was created as version 1.7, and encrypted as 256-bit AES. pdf 创建为 1.7 版,并加密为 256 位 AES。 Does anyone have an example in Java for reading this type of ecncrypted pdf.有没有人在 Java 中有一个例子来阅读这种类型的加密 pdf。

Currently my code reads all pdf previous versions without any errors, the previous versions are encrypted at 128 bit encryption.目前我的代码读取所有 pdf 以前的版本没有任何错误,以前的版本以 128 位加密进行加密。

        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.修订版 6 包含在 PDF 2.0 的“ISO 32000-2”中。 Since PDF 2.0 is not yet an official standard iText does not support it.由于 PDF 2.0 还不是官方标准,iText 不支持它。 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. Adobe 已经实施了它,即使它尚未公开可用且尚未发布(因此由于更改),这对他们来说是一个错误的决定。 After the standard has been released iText will also support it but you'll have to wait for that.标准发布后,iText 也将支持它,但您必须等待。 Until then regenerate that document with Adobe Acrobat using a "lower" encryption algorithm (eg revision 1-5).在此之前,使用“较低”加密算法(例如修订版 1-5)使用 Adob​​e Acrobat 重新生成该文档。

Update in 2021: The standard has been released in 2017, so Revision 6 is good to go. 2021 年更新:该标准已于 2017 年发布,因此修订版 6 很不错。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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