Adding Javascript to existing Pdf

Hi,

I’m trying to add Javascript to an existing Pdf document in a servlet. It doesn’t fail or give me any errors, but the returned Pdf doesn’t open the print dialog on open. It does have the watermark, “Evaluation Only. Created with Aspose.Pdf…”. I’m using a trial version to see if it will meet my project requirements. Is this functionality disabled in the trial version, or is something wrong with my code?

response.setContentType(“application/pdf”);
Part filePart = request.getPart(“file”);
InputStream fileContent = filePart.getInputStream();
Document doc = new Document(fileContent);
JavascriptAction javaScript=new JavascriptAction(“this.print({bUI:true,bSilent:false});”);
doc.setOpenAction(javaScript);
doc.save(response.getOutputStream());

Thanks in advance :slight_smile:
Jeff

Found the answer to my own question. My code is fine, the problem was with the pdf document that I was using for testing. It was a secured document. I used a different pdf file to test with and discovered that everything is working as it should.

Hi Jeff,


Thanks for your feedback. It is good to know that you have managed to resolve issue at your own. Moreover, you may please make a request for 30 days temporary license to evaluate our product without any evaluation limitation.

Please feel free to ask any question or concern, we will be more than happy to extend our support.

Best Regards,