title: How to programatically open a PDF with a User password
body: <p>This is related to my <a href="https://stackoverflow.com/questions/14581578/how-to-disable-function-keys-in-a-pdf-displayed-in-a-jsp-using-object-and-henc"> other question</a>...  hope this one has a solution.</p>
  
  <p>The requirement is to display a password-protected PDF in the browser but to pass the User password programatically. I create a PDF using Jasper and set the user password as follows:<br>
        exporter.setParameter(JRPdfExporterParameter.USER_PASSWORD, userPassword);</p>
  
  <p>As soon as the PDF is created, it has to be displayed in the screen. While displaying in the browser, the user should not be prompted to key in the password ans hence the password should be supplied by the application However, if the user downloads the PDF and then tries to open it, he should be prompted to enter the password.<br>
  [Edit]: I am looking for an approach that does NOT involve licensed tools</p>