Java – automatically opens the print dialog box when opening PDF using iText

I need to be able to automatically provide a print dialog when opening PDF I need JavaScript to do this. I wonder if it is possible for me to attach the JavaScript using iText? This will be clearer because I'm already using the iText library Otherwise, is there a better way? Currently used:

Document document = new Document();
document.add(New Paragraph("<script type="text/javascript">print();</script>"));

However, this will not make any changes to the PDF, but it will still not print when opened

Thank you in advance

Solution

I used iText API calls to do similar things without javascript:

PdfWriter writer = ...;
PdfAction action = new PdfAction(PdfAction.PRINTDIALOG);
writer.setOpenAction(action);
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>