title: Remove encryption from PDF file using Apache PDFBox
body: <p>With <a href="http://qpdf.sourceforge.net/" rel="nofollow noreferrer">QPDF</a>, you can simply remove <em>restrictions / encryption</em> from a PDF file like so:</p>
  <pre><code>qpdf --decrypt infile outfile
  </code></pre>
  <p>I would like to do the same thing with <a href="https://pdfbox.apache.org/" rel="nofollow noreferrer">PDFBox</a> in Java:</p>
  <pre><code>PDDocument doc = PDDocument.load(inputFilename);
  if (doc.isEncrypted()) {
     // remove the encryption to alter the document
  }
  </code></pre>
  <p>I've tried this with <a href="https://pdfbox.apache.org/docs/2.0.1/javadocs/org/apache/pdfbox/pdmodel/encryption/StandardDecryptionMaterial.html" rel="nofollow noreferrer"><code>StandardDecryptionMaterial</code></a>, but I have no idea what the owner password is. How does QPDF does this?</p>
  <p>Sample document:<br />
  <a href="https://issues.apache.org/jira/secure/attachment/12514714/in.pdf" rel="nofollow noreferrer">https://issues.apache.org/jira/secure/attachment/12514714/in.pdf</a></p>