如何使用PDFBOX加载受密码保护的PDF表单

前端之家收集整理的这篇文章主要介绍了如何使用PDFBOX加载受密码保护的PDF表单前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
如何使用PDFBox加载受密码保护的PDF表单

我有一小段代码来加载不受保护的PDF表单

PDDocument pdfDoc;
  pdfDoc = PDDocument.load(filePath);

谁能帮我吗 ..
谢谢

解决方法

试试这段代码
private void openPDFDoc(final File pdfFile) throws Exception {
        File originalPDF = pdfFile;
        PDFParser parser = new PDFParser(new BufferedInputStream(new FileInputStream(
                originalPDF)));
        parser.parse();

        PDDocument originialPdfDoc = parser.getPDDocument();

        boolean isOriginalDocEncrypted = originialPdfDoc.isEncrypted();
        if (isOriginalDocEncrypted) {
            originialPdfDoc.openProtection(new StandardDecryptionMaterial("password"));
        }
    }
原文链接:https://www.f2er.com/html/226897.html

猜你在找的HTML相关文章