I need to be able provide the print dialog automatically when a pdf is opened. I need to do it with javascript and I was wondering if it is possible for me to append said javascript using iText? It would be much cleaner for me to do so because I am currently already utilizing the iText library. Otherwise is there a better way to do this? Currently using:
Document document = new Document();
document.add(New Paragraph("<script type="text/javascript">print();</script>"));
This, however, makes no changes to the pdf but still does not print when it is opened.
Thanks in advance.
I did something like this without Javascript, using iText API calls:
PdfWriter writer = ...;
PdfAction action = new PdfAction(PdfAction.PRINTDIALOG);
writer.setOpenAction(action);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With