Remove PDF Restrictions

The Java code below removes any PDF restrictions if they exist on the document .  The program accepts two arguments, the input and output file names, which can be the same if desired.  The program requires a couple pieces from the PDFBox subproject library, available at

This code will not open a PDF that requires a master password, but it's a simple addition to add that to the PDDocument.load().


import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.encryption.InvalidPasswordException;

public class pdfRemove {

  public static void main(String[] args) throws InvalidPasswordException, IOException {
    File file = new File(args[0]); 
PDDocument document = PDDocument.load(file);

    if (document.isEncrypted()) {
} File(args[1]));

No comments:

Post a Comment

Process Attachments from DMARC Reporting Emails

Below is the Google App Script code I wrote to process emails and save attachments.  The purpose is stated in the comments at the top of the...