使用iText打开PDF时自动打开打印对话框 [英] Open print dialog automatically when PDF opened, using iText

查看:362
本文介绍了使用iText打开PDF时自动打开打印对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要能够在打开pdf时自动提供打印对话框。我需要用javascript来做这件事,我想知道我是否有可能使用iText附加所述javascript?这样做会更加清晰,因为我目前已经在使用iText库了。否则有更好的方法吗?目前使用:

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>"));

但是,这不会对pdf进行任何更改,但在打开时仍然无法打印。

This, however, makes no changes to the pdf but still does not print when it is opened.

提前致谢。

推荐答案

我做了类似的事,没有Javascript ,使用iText API调用:

I did something like this without Javascript, using iText API calls:

PdfWriter writer = ...;
PdfAction action = new PdfAction(PdfAction.PRINTDIALOG);
writer.setOpenAction(action);

这篇关于使用iText打开PDF时自动打开打印对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆