admin管理员组文章数量:1336397
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 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.
Share Improve this question edited Dec 3, 2012 at 3:02 wrschneider 18.8k17 gold badges107 silver badges189 bronze badges asked Dec 3, 2012 at 2:53 sam.tldrsam.tldr 653 silver badges9 bronze badges 2- 1 I don't think that's possible, the browser doesn't know when the PDF is open, and surely can't access the separate process for the PDF to tell to be printed. – Rubens Mariuzzo Commented Dec 3, 2012 at 2:57
- I've been told you can automatically print a pdf using javascript see: fpdf/en/script/script36.php However my question is if you can insert this javascript using iText – sam.tldr Commented Dec 3, 2012 at 3:03
1 Answer
Reset to default 7I did something like this without Javascript, using iText API calls:
PdfWriter writer = ...;
PdfAction action = new PdfAction(PdfAction.PRINTDIALOG);
writer.setOpenAction(action);
本文标签: javaOpen print dialog automatically when PDF openedusing iTextStack Overflow
版权声明:本文标题:java - Open print dialog automatically when PDF opened, using iText - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742332703a2455012.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论