Advanced printing features
Advanced ScriptX client-side printing functionality can only be used with a paid-for publishing license.
Printing html documents with ScriptX and its enhanced features follows a similar pattern to that for Basic printing with ScriptX:
- Enable advanced printing by authoring the MeadCo Security Manager OBJECT tag.
- Enable printing by authoring the MeadCo ScriptX OBJECT tag on the document.
- Author the required UI, for example a button which when clicked will print the document.
- Develop the script that runs in response to a UI action, such as the button click. The script will set required printing attributes and start the print action.
In other words, the only difference from ‘basic’ printing is the addition of the MeadCo Security Manager OBJECT, this Internet Explorer add‑on ensures that advanced functionality is only available from licensed publishers and has been approved by the user by their acceptance of the license.
How to enable Advanced Printing Features
A ScriptX-enabled client-side document is defined as one on which the MeadCo Security Manager and ScriptX object blocks appear in the <BODY> of the document thus:
The Security Manager object refers to two files: smsx.cab and sxlic.mlf.
Nothing should be ‘installed’ on your servers - they are simply used as file storage for smsx.cab (the binaries) and sxlic.mlf (your unique publishing license).
For a discussion of Installation optons please see Installing ScriptX on Client PCs; the only change is that when using smsx.cab, the CODEBASE attribute is authored on the MeadCo Security Manager object rather than the MeadCo ScriptX object.
About the publishing license
sxlic.mlf is your client-side Security Manager publishing license, issued to you in the form of an unique .MLF file of c. 6Kb. Each license has a unique GUID, the revision number will increment with each change or renewal of the license. These details will be provided to you with the license.
For ease of system maintenance it is often preferable to a have single current copy of sxlic.mlf located centrally. The file does not have to reside at a licensed address so long as all your ScriptX-enabled documents are allowed to ‘see’ it.
Your publishing license clearly identifies your organisation and the ‘active’ content you are offering (in this case, advanced printing) in a completely unambiguous way. Except on an intranet (where the ‘Silent’ cost-option is available) it is the user who is given the option to accept or decline to view the content validated by your license.
Your publishing license will work with every existing and future version of ScriptX. It does not have to be updated when the ScriptX software is updated.
All Security Manager publishing licenses are renewable and valid for one or more years.
For more information about licensing, please see Client-side Licensing.
Event handling script - formatting printing attributes and printing
A typical function call to set used advanced print features and formatting and print a top-level document client-side could look like this:
Notice that we call all ScriptX functions by reference to the ID of the on-page ScriptX object - usually ‘factory’.
Some of the advanced features enabled with a publishing license are:
- Control over the printing of a document's background color and images (printBackground).
- A SetMarginMeasure method to ensure that the chosen unit of measure for margins (inches or millimeters) will be consistent across machines with different locale settings.
- Facilities to select a non-default printer, paper size & source, page range & collation and number of copies to print.
- Reliability and scalability. The PrintHTML(url) method can queue and print any number of documents without compromising system performance. This is especially important for server side printing. On the client-side, PrintHTML works in the HTTP session context of the calling page (SSL is supported as well).
- Precise tracking of spooler activity (IsSpooling, WaitForSpoolingComplete, onafterprint). By default, when the Internet Explorer window is closed or the page navigated away from whilst a print-out is still being spooled, the user will be prompted. The prompt can be customized or disabled (onbeforeunload).
- Print settings changes (headers, footers, margins, paper orientation, printer name, paper size, paper source, page range selection, number of copies, collation, duplex mode) once made from script now become active for Internet Explorer's native UI Print… and Page Setup… commands, as well as for the native window.print() script method, during the time that the document is displayed. Now an author doesn't need to put a [Print] button on an HTML page.
- Internet Explorer's native printing UI can be trapped and cancelled, or handled in a particular way (disableUI, onuserprint, onuserprintpreview, onuserpagesetup). A document's DHTML user interface can also be updated in response to user changes in the Page Setup and Print dialogs (onpagesetup). See the complete UI sample for an illustration of UI handling.
- All changes made to print settings affect only the current document (in the current tab) when it is printed or previewed. Settings are untouched in other IE windows or tabs and will not apply to any other documents viewed in the current window/tab.
- A redirect of print data can be made to a specified file name (printToFileName).
- Basic printing of Microsoft OfficeTM documents.
- Printing of PDF documents (PrintPDF and BatchPrintPDF).
- In your own code, we recommend that you place the ScriptX <OBJECT> elements in the document's <BODY> container.
- Start to script the ScriptX object only when the page is fully loaded i.e. only once the body.onload event has occured.
- You should never call the ScriptX object from in-line script that is run when the document is first parsed. This technique will guarantee inconsistencies in the working of your code because of the timing errors that can result.
- The ‘de-facto’ standard - as started by this documentation - is to use the id ‘factory’ for the ScriptX object. Any id that is desired may be used.
- For simplicity, these documents directly refer to the object via its id rather than using document.getElementById(). Either approach is acceptable.
- If the samples are inspected via View Source it will be seen that the jQuery library is used in the samples, along with a wrapper class to safely access the ScriptX object. The use of jQuery etc is also entirely optional.
- Only one ScriptX object can appear on any one document.
- You can not use CreateObject or new ActiveXObject to create the ScriptX object and ScriptX-enable a page.