Return to Snippet

Revision: 72662
at October 12, 2017 21:36 by markt22


Initial Code
/**
 * @param args the command line arguments
 * @throws java.io.IOException
 */
public static void main(String[] args) throws IOException {
    PDDocument document = new PDDocument();
    PDPage page = new PDPage(PDRectangle.A4);
    
    document.addPage(page);
    
    AccessPermission permssion = new AccessPermission();         
    
    StandardProtectionPolicy policy = new StandardProtectionPolicy("ownerPassword", "userPassword", permssion);
    
    policy.setEncryptionKeyLength(128);
    
    policy.setPermissions(permssion);
    
    document.protect(policy);
    
    document.save("");
    document.close();
}

Initial URL


Initial Description
Creates a new document with a single page and adds standard encryption to it

Initial Title
PDFBox: Encrypting a PDF

Initial Tags


Initial Language
Java