Introduction

This walk-through illustrates taking a classic document that has a controlled print experience and works only in Internet Explorer and making it work with ScriptX.Services in any browser on any platform using the minimum amount of development effort and making as few changes as possible (though more changes might be desirable).

For the purposes of this illustration we will serve the sample content from the ScriptX Samples domain. If you wish to explore in more detail yourself with different browsers you can download the sources from the  ThenToNow repository and use your own localhost server. The sources use the evaluation license which lists localhost as a valid domain.

An alternative step-by-step walkthrough is available on  ScriptX Samples.

The starter code

The sample assumes that ScriptX.Add-on for Internet Explorer is aleady installed (no codebase). The evaluation license is used to enable advanced features to be used on content served from a web server on localhost.

  • Ensures a margin measure is used independent of user settings.
  • Headers and footers using HTML.

An initialisation function is run when the document loads to engage the ScriptX.Add-on override of the browser UI and to describe the print layout including using enhanced formatting for page headers and footers with the use of images.

Browse to the sample

Open Internet Explorer and go to the address  //scriptxprintsamples.meadroid.com/ThenToNow/Then

Problems
  • No doctype is provided, Internet Explorer 11 will assume standards mode, older versions will assume IE 5 mode (!) and evergreen browsers will output a complaint to the browser console.
  • No user interface is provided in the html so it is assumed that ScriptX.Add-on for Internet Explorer will override the browser UI and the user can use the standard browser controls to print or preview; gear menu etc.
Content sources for ScriptX enabled content
  • With a suitable publishing license ScriptX enabled html content can be loaded from disk into Internet Explorer 11, or even earlier versions of Internet Explorer. A warning will be given, and permission sought to run ActiveX Controls and then the sample would work.
  • However, ScriptX.Services will not work with content loaded from disk; the content must be served from a web server and the domain/URL address FROM which you are serving the ScriptX-enabled content must be listed in a MeadCo Client side publishing license.
  • For the purposes of this illustration we will serve the sample content from the ScriptX Samples domain. If you wish to explore in more detail yourself with different browsers you can download the sources from the  ThenToNow repository and use your own localhost server. The sources use the evaluation license which lists localhost as a valid domain.

The following sections work through taking this code and making it work with ScriptX.Services with minimal effort.

Stage 1 - Add some UI
Stage 2 - Add ScriptX.Services scripts
Stage 3 - Summary and review

At this stage the sample works in the same way in all browsers though the main javascript has not changed and the code could be put into production. However, some further improvements would be worthwhile.

Stage 4: Error reporting
Stage 5: Prompted printing

Again, the code could be put into production and it is robust.

A commonly used feature of ScriptX.Add is the WaitForSpoolingComplete() function. This function enables asynchronous processing of printing by the browser whilst the javascript is synchronous - this enables code to "wait" until printing is complete and then, for example, continue with a workflow.

Stage 6: Preparing for advanced uses
Stage 7: WaitForSpoolingComplete