This is related to my other question… hope this one has a solution.
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:
exporter.setParameter(JRPdfExporterParameter.USER_PASSWORD, userPassword);
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.
[Edit]: I am looking for an approach that does NOT involve licensed tools
I’m not sure whether something of this is possible. On the browser the pdf is opened by a Plugin – usually Adobe Reader plug-in. There are also other makes apart from Adobe Reader. Chrome has it own plugin.
On the browser when it detects any PDF file – the rendering plugin takes over – and this is browser specific. You hardly have any control.
Easy alternative is to show the same content in a web page – probably a modal window if the content is sensitive and give a link to download the password protected pdf file
my 2c