private void extract(String pdfFile, String password) throws IOException { try (PDDocument document = PDDocument.load(new File(pdfFile), password)) { AccessPermission ap = document.getCurrentAccessPermission(); if (!ap.canExtractContent()) { throw new IOException("You do not have permission to extract images"); } for (PDPage page : document.getPages()) { ImageGraphicsEngine extractor = new ImageGraphicsEngine(page); extractor.run(); } } }
if (!ap.canExtractContent())
if( ! ap.canExtractContent() )
/** * This will tell if the access permission corresponds to owner * access permission (no restriction). * * @return true if the access permission does not restrict the use of the document */ public boolean isOwnerPermission() { return (this.canAssembleDocument() && this.canExtractContent() && this.canExtractForAccessibility() && this.canFillInForm() && this.canModify() && this.canModifyAnnotations() && this.canPrint() && this.canPrintDegraded() ); }
@Override Object[][] getFlagBits() { AccessPermission ap = new AccessPermission(encryptDictionary.getInt(COSName.P)); return new Object[][]{ new Object[]{3, "can print", ap.canPrint()}, new Object[]{4, "can modify", ap.canModify()}, new Object[]{5, "can extract content", ap.canExtractContent()}, new Object[]{6, "can modify annotations", ap.canModifyAnnotations()}, new Object[]{9, "can fill in form fields", ap.canFillInForm()}, new Object[]{10, "can extract for accessibility", ap.canExtractForAccessibility()}, new Object[]{11, "can assemble document", ap.canAssembleDocument()}, new Object[]{12, "can print degraded", ap.canPrintDegraded()}, }; } }
Boolean.toString(ap.canExtractForAccessibility())); metadata.set(AccessPermissions.EXTRACT_CONTENT, Boolean.toString(ap.canExtractContent())); metadata.set(AccessPermissions.ASSEMBLE_DOCUMENT, Boolean.toString(ap.canAssembleDocument()));
cachedMap.put("Can Print", String.valueOf(permissions.canPrint())); cachedMap.put("Can Modify", String.valueOf(permissions.canModify())); cachedMap.put("Can Extract", String.valueOf(permissions.canExtractContent())); cachedMap.put("Can Modify Annotations", String.valueOf(permissions.canModifyAnnotations())); cachedMap.put("Can Fill Forms", String.valueOf(permissions.canFillInForm()));
.getCurrentAccessPermission(); if (!ap.canExtractContent()) { throw new IOException( "You do not have permission to extract text.");
document.getCurrentAccessPermission(); if (!ap.canExtractContent()) { throw new IOException( "You do not have permission to extract text.");
document.getCurrentAccessPermission(); if (!ap.canExtractContent()) { throw new IOException( "You do not have permission to extract text.");
private void extract(String pdfFile, String password) throws IOException { PDDocument document = null; try { document = PDDocument.load(new File(pdfFile), password); AccessPermission ap = document.getCurrentAccessPermission(); if (! ap.canExtractContent()) { throw new IOException("You do not have permission to extract images"); } for (PDPage page : document.getPages()) { ImageGraphicsEngine extractor = new ImageGraphicsEngine(page); extractor.run(); } } finally { if (document != null) { document.close(); } } }
if( ! ap.canExtractContent() )
this.isFillingSigningAllowed = accessPermissions.canFillInForm(); this.isDocumentAssemblyAllowed = accessPermissions.canAssembleDocument(); this.isExtractContentAllowed = accessPermissions.canExtractContent(); this.isExtractAccessibilityAllowed = accessPermissions.canExtractForAccessibility();
if( ! ap.canExtractContent() )
/** * This will tell if the access permission corresponds to owner * access permission (no restriction). * * @return true if the access permission does not restrict the use of the document */ public boolean isOwnerPermission() { return (this.canAssembleDocument() && this.canExtractContent() && this.canExtractForAccessibility() && this.canFillInForm() && this.canModify() && this.canModifyAnnotations() && this.canPrint() && this.canPrintDegraded() ); }
/** * This will tell if the access permission corresponds to owner * access permission (no restriction). * * @return true if the access permission does not restrict the use of the document */ public boolean isOwnerPermission() { return (this.canAssembleDocument() && this.canExtractContent() && this.canExtractForAccessibility() && this.canFillInForm() && this.canModify() && this.canModifyAnnotations() && this.canPrint() && this.canPrintDegraded() ); }
Boolean.toString(ap.canExtractForAccessibility())); metadata.set(AccessPermissions.EXTRACT_CONTENT, Boolean.toString(ap.canExtractContent())); metadata.set(AccessPermissions.ASSEMBLE_DOCUMENT, Boolean.toString(ap.canAssembleDocument()));
Boolean.toString(ap.canExtractForAccessibility())); metadata.set(AccessPermissions.EXTRACT_CONTENT, Boolean.toString(ap.canExtractContent())); metadata.set(AccessPermissions.ASSEMBLE_DOCUMENT, Boolean.toString(ap.canAssembleDocument()));
Boolean.toString(ap.canExtractForAccessibility())); metadata.set(AccessPermissions.EXTRACT_CONTENT, Boolean.toString(ap.canExtractContent())); metadata.set(AccessPermissions.ASSEMBLE_DOCUMENT, Boolean.toString(ap.canAssembleDocument()));