获取 xul 打印中的 Printprogress

发布于 2024-10-17 19:14:48 字数 932 浏览 4 评论 0原文

我正在做这个 xul 离线应用程序,它有很多打印作业。是否有办法从 xul print 获取进度/监听器,表示它已完成?我已经被这个问题困扰了一段时间了,请分享一些关于如何继续的想法。打印的代码如下。

xul文件

<iframe type="content-primary" flex="1" src="index.html"  />

打印函数

function getWebBrowserPrint()
{
return _content.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIWebBrowserPrint);
}

function printpdf() {
var webBrowserPrint= getWebBrowserPrint();
var gPrintSettings = webBrowserPrint.globalPrintSettings;

gPrintSettings.footerStrLeft = "";
gPrintSettings.footerStrCenter = "";
gPrintSettings.footerStrRight = "";
gPrintSettings.headerStrLeft = "";
gPrintSettings.headerStrCenter = "";
gPrintSettings.headerStrRight = "";
gPrintSettings.printSilent = true;
gPrintSettings.showPrintProgress = true;
gPrintSettings.printerName = "PDF Writer";
webBrowserPrint.print(gPrintSettings, null);
}

I am doing this xul offline application which has lots of print job. Is there anyway to get the progress/listener from xul print, saying it is complete? I am stuck with this for sometime now, please share some ideas on how to proceed. The code for printing is as follows.

xul file

<iframe type="content-primary" flex="1" src="index.html"  />

Print Function

function getWebBrowserPrint()
{
return _content.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIWebBrowserPrint);
}

function printpdf() {
var webBrowserPrint= getWebBrowserPrint();
var gPrintSettings = webBrowserPrint.globalPrintSettings;

gPrintSettings.footerStrLeft = "";
gPrintSettings.footerStrCenter = "";
gPrintSettings.footerStrRight = "";
gPrintSettings.headerStrLeft = "";
gPrintSettings.headerStrCenter = "";
gPrintSettings.headerStrRight = "";
gPrintSettings.printSilent = true;
gPrintSettings.showPrintProgress = true;
gPrintSettings.printerName = "PDF Writer";
webBrowserPrint.print(gPrintSettings, null);
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

﹉夏雨初晴づ 2024-10-24 19:14:48

webBrowserPrint.print 的第二个参数可以是 nsIWebProgressListener 对象。特别是,当打印完成时,您将收到一个 onStateChange 回调,其中包含一个包含 STATE_STOP 的标志。

The second parameter to webBrowserPrint.print can be an nsIWebProgressListener object. In particular you'll get an onStateChange callback with a flag including STATE_STOP when printing has finished.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文