neodynamic / JSPrintManager

Advanced Client-side Printing & Scanning Solution for Javascript
https://www.neodynamic.com/products/printing/js-print-manager/
257 stars 137 forks source link

Event to track success of printjob #43

Closed ll-venkat-n closed 2 years ago

ll-venkat-n commented 2 years ago

Hi, do we any event to know the status of print job ?

On success of printjob, we need to do extra task but current we do not have a way to track.

we have onError or onFinished but not for success.

if error we should stop next action and if success do some Database operation so any better way to do this.

neodynamic commented 2 years ago

This is a sample https://www.neodynamic.com/articles/How-to-trace-Print-Job-Status-from-Javascript/ The event info is returned by the printer driver. All those update events are "accumulative" and for the print job to be completed and successful you should keep tracking both completed-pages and total-pages. Both could return "null" or a digit. If both ends being a digit and equal, then it can be considered that printing was successful

ll-venkat-n commented 2 years ago

i tried both those onUpdated and onFinished and onError and only OnError calling and onFinished or onUpdated not calling at all. am i missing something ? here is my code : public static printLabel(printCommands: string, printerType: LabelType): Promise { const clientPrintJob = new JSPM.ClientPrintJob(); clientPrintJob.clientPrinter = new JSPM.InstalledPrinter( PrintManager.printerName(printerType) );

    JSPM.JSPrintManager.getPrinters().then(function (printersList) {
        console.log('printersList' + printersList)
    });

    clientPrintJob.printerCommands = printCommands;
    // console.log(clientPrintJob.printerCommands);
    clientPrintJob.onUpdated = function (data) {
        console.info('########onUpdated' + JSON.stringify(data));
    };
    clientPrintJob.onUpdate = function (data, last) {
        console.info('########onUpdate' + JSON.stringify(data));
        console.info('########last' + last);
    };
    clientPrintJob.onFinished = function (data) {
        console.info('##########onFinished' + JSON.stringify(data));
    };
    clientPrintJob.onError = function (data) {
        console.info('onError####' + JSON.stringify(data));
    };
    return clientPrintJob.sendToClient();
}

}

Only error cases like printer Name wrong , i am getting onError event only and onFinished call for error only not for success.

neodynamic commented 2 years ago

Print Job status is available when printing files and not when printing raw commands as in your case.

ll-venkat-n commented 2 years ago

how do we check status in our case as we need to print [Zebra ZPL] so if print fails or any issues how to stop and get success status or print. Really if you have some suggestions.

neodynamic commented 2 years ago

In that case you should send the appropriate ZPL commands to know the printer status but BIDI comm through the driver is not supported by our product. Our product supports Serial port BIDI comm only.

ll-venkat-n commented 2 years ago

Could you please share more details on BIDI comm this is the first time we are integrating. our requirements is

if we have different approach or any other alternatives also please suggest. we are planing to buy license soon.

neodynamic commented 2 years ago

As we wrote before, if your printer is NOT connected through a COM port, then our product cannot be used to get info from the printer

AnsonHwang86 commented 1 week ago

I notice this issues was closed marked with COMPLETED, is it means this feature was finished on v7.0?