Pdf.js: How can I get a feedback after click printButton or cancelButton?

Created on 23 Aug 2016  ·  3Comments  ·  Source: mozilla/pdf.js

Web browser: Chrome

I click printButton on viwer.html, then it triggers the browser method of window.print(),
it open a preview page.

Here is the problem:
How can I get a feedback after click printButton or cancelButton on this preview page see blow?
because I need to execute a callback function after print success but not cancel printing.

pages

Most helpful comment

thanks for your kindly reply, I have tried to listen for the afterprint event but that is not I really want, since afterprint event is fired when the printing dialog closed no matter I click print button or cancel print button at last on the open window of printing dialog.

what make me puzzled is that the event window.print() has no any return value to let me know whether it print successful or cancel or stop printing.

so how I can confirm my printing task really success but not be cancel at last?

在 2016年8月23日,下午7:43,Jonas Jenwald [email protected] 写道:

You should be able to listen for the afterprint event (see https://developer.mozilla.org/en-US/docs/Web/Events/afterprint https://developer.mozilla.org/en-US/docs/Web/Events/afterprint and https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onafterprint https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onafterprint), which is the event that the viewer uses to cleanup after printing (in https://github.com/mozilla/pdf.js/blob/master/web/app.js#L2312-L2314 https://github.com/mozilla/pdf.js/blob/master/web/app.js#L2312-L2314 and https://github.com/mozilla/pdf.js/blob/master/web/app.js#L1167-L1180 https://github.com/mozilla/pdf.js/blob/master/web/app.js#L1167-L1180).

Closing as answered.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub https://github.com/mozilla/pdf.js/issues/7558#issuecomment-241705562, or mute the thread https://github.com/notifications/unsubscribe-auth/ARE_brB9oi2RsgZZlewPzU0umg7nzfvTks5qitz9gaJpZM4Jqhtd.

All 3 comments

You should be able to listen for the afterprint event (see https://developer.mozilla.org/en-US/docs/Web/Events/afterprint and https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onafterprint), which is the event that the viewer uses to cleanup after printing (in https://github.com/mozilla/pdf.js/blob/master/web/app.js#L2312-L2314 and https://github.com/mozilla/pdf.js/blob/master/web/app.js#L1167-L1180).

Closing as answered.

thanks for your kindly reply, I have tried to listen for the afterprint event but that is not I really want, since afterprint event is fired when the printing dialog closed no matter I click print button or cancel print button at last on the open window of printing dialog.

what make me puzzled is that the event window.print() has no any return value to let me know whether it print successful or cancel or stop printing.

so how I can confirm my printing task really success but not be cancel at last?

在 2016年8月23日,下午7:43,Jonas Jenwald [email protected] 写道:

You should be able to listen for the afterprint event (see https://developer.mozilla.org/en-US/docs/Web/Events/afterprint https://developer.mozilla.org/en-US/docs/Web/Events/afterprint and https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onafterprint https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onafterprint), which is the event that the viewer uses to cleanup after printing (in https://github.com/mozilla/pdf.js/blob/master/web/app.js#L2312-L2314 https://github.com/mozilla/pdf.js/blob/master/web/app.js#L2312-L2314 and https://github.com/mozilla/pdf.js/blob/master/web/app.js#L1167-L1180 https://github.com/mozilla/pdf.js/blob/master/web/app.js#L1167-L1180).

Closing as answered.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub https://github.com/mozilla/pdf.js/issues/7558#issuecomment-241705562, or mute the thread https://github.com/notifications/unsubscribe-auth/ARE_brB9oi2RsgZZlewPzU0umg7nzfvTks5qitz9gaJpZM4Jqhtd.

@xingxiaoyiyio Did you find a solution?

Was this page helpful?
0 / 5 - 0 ratings