Print a single remote HTML document

In the 'classic' usage of ScriptX to provide an enhanced printing experience of HTML documents the printing UI is included in the page to be printed.

A work-flow may include a process on the server preparing reports to be printed. The user at their PC may then select one of a number of the pre-prepared reports for printing. Or, a server action may return an HTML document with data obtained from a database populating various content in the document. The user may select a document to be prepared and printed without needing to see or preview the document.

These are both cases for printing of a 'remote' document - in other words download and print the document without displaying it in the browser.

When the PrintHTML() method is used, headers, footers, papersize etc etc, i.e. all the usual formatting (including enhanced formatting) and presentation properties are used to print the downloaded document.

A chosen document can then be printed:

function printDocument(url) {
var p = MeadCo.ScriptX.printing;

p.header = "Finance report&b&p of P&b";
p.footer = "&b&D&b";

// BackgroundPrintURL wraps PrintHTML/PrintHTMLEx()
MeadCo.ScriptX.BackgroundPrintURL(url,false);
}

The printHtml() method implements its own queue and caches printing parameters (including printer to use and so on) - documents are downloaded and once the download is complete, the document is printed.

There are important differences between the behaviour of ScriptX.Add-on an ScriptX.Services.

Illustration

The report cookie for this browser's session with the server is: [a1caa9f9-ba69-4823-9a56-ff44507a76be, created at: 26/05/2020 14:17:07].

If the print process shares this browser's session then the above cookie will be printed on the report when "Print document ..." is used.

This will only be true when you are using ScriptX.Add-on with its default behaviour () and you haven't used Enable OwnQueue. For ScriptX.Add-on, once you have printed, the print type - in-process or out-of-process, will stay the same, use Refresh to switch usage

For ALL other cases, the report with be printed with no-cookie value showing that the session data from this browser's session is not available.

ScriptX.Add-on

In its default usage, users must wait for the entire queue to download and print before navigating away from the page. Calling the OwnQueue() method moves the printHtml queue to its own independent process and users are free to get on with their work.

However, there is a price to pay for this flexibility when dealing with dynamic server side systems that rely upon maintenance of session information and in particular those that rely upon the use of cookies to maintain that information.

In its default usage, the printHtml() queue shares session information transferred to the browser by the server with the Internet Explorer browser session. For example, session cookies are shared and the server will believe that requests made by the queue are in the same session as previous requests from the browser and so, for example, log-on information etc is 'preserved'.

When OwnQueue has been called, a new independent process is created and no session information (cookies) from the parent browser are transferred. Requests made by the queue to the server will therefore appear to be from a new browser session and any log-on information that is persisted by cookies will have been 'lost'. A typical result of this is that rather than the expected report being produced, a logon page or site default page is printed (the requested report page will have determined that the session is not logged on and will perform a redirect to the default/logon page).

ScriptX.Services

With ScriptX.Services all printing is in its own queue operating independently of the browser (it may be on a physically separate machine).

Requests made by ScriptX.Services for the document therefore appear to be from a new source and there will be no log-on information or any information that is persisted to cookies that might be available to the originating browser. A typical result of this is that rather than the expected report being produced, a logon page or site default page is printed (the requested report page will have determined that the session is not logged on and will perform a redirect to the default/logon page).

Activity log  ::