Estimating print performance

PrintHTML() is a fire and forget method and if anything goes wrong no one will know other than nothing has appeared at the printer. The  PrintHTMLEx API method provides for monitoring the progress of the job and notification of errors.

While it is possible to use the callback function to monitor for job complete, there is a function that will do this: WaitForSpoolingComplete(). In addition WaitForSpoolingCompete() works with any print function other than the direct printing APIs which are synchronous.

With WaitForSpoolingComplete() a reasonable approximation to determining job time can be implemented:

let jobStartTime = Date.now();
let bPrint = await MeadCo.ScriptX.BackgroundPrintURL2(sUrl, false);
if ( bPrint ) {
    app.BusyStatus.Show("Please wait for printing to complete ...", "Printing ...");
    try {
        await MeadCo.ScriptX.WaitForSpoolingComplete();
        reportTelemetry(sUrl,"",Date.now()-jobStartTime)
    } catch (e) {
        reportTelemetry(sUrl,e,Date.now()-jobStartTime)
        if (typeof app.Messages.PrintErrorBox === "function") {
            app.Messages.PrintErrorBox(e);
        }
        else {
            alert("An error occurred while printing\n\n" + e);
        }
    }
}

PrintHTMLEx() is PrintHTML() with information

The only difference between the APIs is the addition of the callback function and callback data. Internally, the implementation of PrintHTML() calls  PrintHTMLEx API . PrintHTML() retained for compatibility with production code but we recommend using PrintHTMLEx() in new code.

Activity log  ::