Common use of a "print" window

A common use case is that of a child window that is opened to print some content and when the print completes the window is closed.

The closing of the window requires the use of the WaitForSpooling() complete function to ensure that the window is only closed once the print processing as been completed and the print job has been delivered to the printer.

As discussed, unlike the majority of javascript code used with ScriptX.Addon the use of WaitForSpoolingComplete() with ScriptX.Services requires changes to the javascript code.

This sample does not use the MeadCoJS library to hide differences between .Addon and .Services implementation but directly checks for the use of ScriptX.Services and uses the modified form of the ScriptX.Services WaitForSpoolingComplete() function to provide the required behaviour.

Use "Open print window" to see a working example (prints to the default printer) and use "Print in this" to be able to view source and see the log of behaviour: open the developer tools pane using F12 to see the logs.