PDFBox setOpenAction 打印 [英] PDFBox setOpenAction to print

查看:63
本文介绍了PDFBox setOpenAction 打印的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 PDFBox 的新手,我需要在打开 PDF 时将其发送到打印机.我们正在使用 PDFBox api 来生成 PDF.我使用以下代码尝试在打开时设置操作,但没有任何效果.请帮忙.我使用过不同的 javascript,比如 window.print();this.print();打印();

I'm new to PDFBox, I have a requirement to send the PDF to the printer when it is opened. We are using PDFBox api to generate the PDFs. I have used the below code to try setting the action on open but nothing worked. Please help. I have used different javascript like window.print(); this.print(); print();

    PDDocument doc = new PDDocument();
    PDActionJavaScript javascript=new PDActionJavaScript("app.print();");
    doc.getDocumentCatalog().setOpenAction(javascript);

推荐答案

试试这个 PDActionJavaScript("this.print({bUI: false, bSilent: true, bShrinkToFit: true});");

try this PDActionJavaScript("this.print({bUI: false, bSilent: true, bShrinkToFit: true});");

这篇关于PDFBox setOpenAction 打印的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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