crabbly / Print.js

A tiny javascript library to help printing from the web.
MIT License
4.28k stars 672 forks source link

Event listener when printing in silent mode. #701

Open jshawberry opened 6 months ago

jshawberry commented 6 months ago

I have an application using printJS, and I have the following call:

    printJS({
        printable: printableContent,
        type: 'raw-html',
        onPrintDialogClose: myMethod,
        title: 'My Title'
    });

I need to print silently (ex. print.always_print_silent on Firefox). Which I have configured in my client browser successfully.

I have also added the following event listeners for "focus" and "afterprint"...

    window.addEventListener("afterprint", function(event)
    {
        myMethod();
    });

    window.addEventListener("focus", function(event)
    {
        myMethod();
    });

However, none of these event listeners get triggered when I'm in silent print mode. The onPrintDialogClose feature does not get triggered either.

How do I determine when the print job finishes if I'm in silent print mode?