PDDocument doc = PDDocument.load(in); StandardDecryptionMaterial dm = new StandardDecryptionMaterial("password"); doc.openProtection(dm);
PDDocument pdfDoc = PDDocument.load(new File("path/to/pdf")); boolean hasOwnerPwd = false; boolean hasUserPwd = false; if(pdfDoc.isEncrypted()){ hasOwnerPwd = true; try{ StandardDecryptionMaterial sdm = new StandardDecryptionMaterial(null); pdfDoc.openProtection(sdm); hasUserPwd = true; } catch(Exception e){ // handle exception } }
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")); } }
final StandardDecryptionMaterial sdm = new StandardDecryptionMaterial( password); document.openProtection(sdm); final AccessPermission ap = document .getCurrentAccessPermission();
final StandardDecryptionMaterial sdm = new StandardDecryptionMaterial(password); document.openProtection(sdm); final AccessPermission ap = document.getCurrentAccessPermission();
final StandardDecryptionMaterial sdm = new StandardDecryptionMaterial(password); document.openProtection(sdm); final AccessPermission ap = document.getCurrentAccessPermission();
document.openProtection(decryptionMaterial); AccessPermission ap = document.getCurrentAccessPermission(); if(ap.isOwnerPermission())
document.openProtection(spm);
document.openProtection(spm);
/** * This is just a shortcut. We often load() and openProtection(). * * @param inBlob Input Blob. * @param inPwd Input password. * @throws NuxeoException */ public static PDDocument load(Blob inBlob, String inPwd) throws NuxeoException { PDDocument pdfDoc; try { pdfDoc = PDDocument.load(inBlob.getStream()); if (pdfDoc.isEncrypted()) { pdfDoc.openProtection(new StandardDecryptionMaterial(inPwd)); } } catch (IOException e) { throw new NuxeoException("Failed to load the PDF", e); } catch (BadSecurityHandlerException | CryptographyException e) { throw new NuxeoException("Failed to decrypt the PDF", e); } return pdfDoc; }
return pdfBlob; pdfDoc.openProtection(new StandardDecryptionMaterial(password)); pdfDoc.setAllSecurityToBeRemoved(true); Blob result = Blobs.createBlobWithExtension(".pdf");
isEncrypted = pdfDoc.isEncrypted(); if (isEncrypted) { pdfDoc.openProtection(new StandardDecryptionMaterial(password));