如何使用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")); } }