Introduction to ScriptX.Services
ScriptX.Services is for use within web applications within any browser. The use of ScriptX.Services provides scripted control of a printing experience within the browser including allowing a choice of the output printer, orientation, page header and footers etc and the initiation of printing.
ScriptX.Services provides developers with the tools for ensuring the consistent formatting and appearance of printed output regardless of the users device or modern browser.
If you are a current licensee of ScriptX.Addon then, for example, ScriptX.Services enables maintaining your investment in your current code:
or, if you are a developer of new applications using common frameworks such as React, Angular, Vue then you might not want to use external modules/libraries but use the Open API to print content from the current document:
This is the output from our cloud service `printing` using a print to PDF print driver.
The result is output with consistent formatting and appearance regardless of the browser and its settings that you are using.
The same idea works with ScriptX.Services hosted not in the cloud but on your own network or on each individual Windows PC and you can print to paper/labels from any browser to any printer available on the network / PC.
ScriptX.Services product variants
Variants provide the optimum solution for your envioronment:
For Windows PC
The closest equivalent to the ScriptX Add‑on for Internet Explorer, the Microsoft Windows (x64) PC service provides for ‘printing’ to any print device available to the client Microsoft Windows (x64) PC.
For On Premise Devices
The on-premise ScriptX.Services is completely under your own control hosted on your own Microsoft Windows (x64) Server and provides for ‘printing’ to any print device available to the server.
Our FREE cloud service provides for ‘printing’ to a PDF or XPS format file which is downloaded by the user. They may open, save or print the file - think of this as an easy way to provide a “download this page as a PDF/XPS document” facility on your website.
ScriptX.Add-on for Internet Explorer uses a deep integration with the Internet Explorer UI and custom templates for the Trident Print engine within Internet Explorer. This enables the Internet Explorer engine to be used to paginate the document and render to the print output device.
The add-on needs to be installed on each client PC - a process that in general requires Administrator privileges and for advanced usage requires a license is accepted and installed by each user of Internet Explorer.
To control the print process the developer writes script code to set required properties on and call methods from the add-on to perform printing and other tasks. Typically the add-on was instantiated with the id 'factory' so code such as this is typical:
As well as working within Internet Explorer we developed ScriptX so that it could be used as an HTML print engine for applications and services such as Internet Information Services (IIS).
In other words, the print technology of ScriptX is tried, tested and used over many years to prove its reliability and robustness.
To support modern browsers on any device with ScriptX.Services we take that technology and deploy it behind a rich Web API on a local web server that provides the interface between the ScriptX print engine on the PC and the client devices.
The interface accepts a stream of html to print and the settings to use and then passes those onto the print engine which then prints the html with the provided settings such as headers, footers, margins, printer to use, papersize to use and so on.
So, instead of the printing being performed within and by the user's browser, the content to be printed is sent from user's browser to ScriptX.Services where it is paginated and rendered to a print device connected to the ScriptX.Services host - the local PC, team server or cloud.
The library will work with both
'.factory' based code and with MeadCoScriptXJS Library based code.
Our ScriptX.Services client libraries support Edge, Chrome, Firefox and Safari (and any modern evergreen browser that supports HTML 5 and ECMAScript 5 or later).
ScriptX.Add-on for Internet Explorer continues to be supported for Internet Explorer.
ScriptX.Add-on provides three three ways of printing HTML content from the browser. Each of these functions prints a 'snapshot' of the content as currently displayed in the browser. ScriptX.Services supports each print function.
Print the page/document
window.factoryobject that fully emulates ScriptX.Add-on.
<script src="/scripts/meadco-core-1.12.0.js"></script> <script src="/scripts/meadco-scriptxprint-1.12.0.js"></script> <script src="/scripts/meadco-scriptxprinthtml-1.12.0).js"></script> <script src="/scripts/meadco-scriptxfactory-1.12.0.js"></script> <script src="/scripts/meadco-scriptxprintlicensing-1.12.0.js"></script> <script src="/scripts/meadco-secmgr-1.12.0.js" data-meadco-license="3cfd70e2-f38f-4ab2-95f4-4ce4c1e39497" data-meadco-license-revision="0" data-meadco-license-path="warehouse" data-meadco-server="http://127.0.0.1:41191"> </script>
To be clear; when the 'Print(false)' function executes, the html as displayed on screen is sent to the local web server along with references to required external resources such as style sheets and images (script references are not sent). The html document is then paginated and rendered.
The settings such as header and footer are not sent with each setting of a property. The values are stored in variables on the client and then sent to the server with the stream of html to print.
Print a remote document
To print a remote document is simple - send the url to be downloaded and printed to the local web server along with the required settings. In otherwords, instead of the stream to print, just the url. The server then requests the HTML content from the url then it is paginated and rendered.
Print document fragments
[aka factory.SetPageRange(); factory.Print()]
The SetPageRange() function sets a flag such that only the content that is selected (either programmatically or by the user) is printed. The requirement for a selection means this is not hugely useful, but the ability to print a fragment of or part of the current html document or even a dynamically generated document fragment without the need to copy it into the DOM is useful.
With ScriptX.Services we can easily do this by taking a snap shot of part of the DOM rather then the whole page DOM when printing the whole document. The html is sent along with references to required external resources such as style sheets and images (script references are not sent). The html is then assembled as a complete document, paginated and rendered.
With our ScriptX.Services libraries you can write the code that works seemlessly with both the ScriptX.Add-on and ScriptX.Services. Whichever browser, which ever device, which ever version of ScriptX, your users will get the same experience with consistent output.
To write once, leave the ScriptX.Add-on object on the page and add the script files. In those browseers that support ScriptX.Add-on it will be used, in those browsers that don't the emulation will be used:
A chance to re-write is always welcome and the very flat properties/methods list of the add-on isn't the design approach that would be taken now.
Our service exposes a rich API for describing the parameters to use on the print and delivering the HTML content to print.
If you are starting new projects now, then you might want to use your preferred library - jQuery, Angular, React, Vue, Axios etc etc to provide the library for calling a REST API and then extract relevant portions from our libraries on ScriptX.Services Client Library for extracting the HTML to send to the rich API.
The choice is yours.
If you have curerent code using ScriptX.Addon - you can continue to use that code if you want to.
Or, you might want to develop optimal code for your solution.