ScriptX - Controlled and Consistent Print Output
  • Getting started
  • My Account
  • Downloads
  • Features
    • ScriptX.Services
    • ScriptX.Add-on
  • Pricing & Licensing
    • ScriptX.Services
    • ScriptX.Add-on
    • Deployment
  • Case Studies
  • About Us
  • Blog
  • Developers
    • Knowledge Bank 
      • ‘How To’ Guides
      • Technical Reference
      • Samples
    • About ScriptX.Services
    • Developer Downloads
    • Codestore
    • Community
  • Contact
Developers ›  Knowledge Bank ›  How To Guides ›  ScriptX.Services ›  Introduction

Introduction

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 is our evolution to providing developers with the tools for ensuring the consistent formatting and appearance of printed output regardless of the users device or modern browser.

For example, maintain investment in current code:

<!-- MeadCo ScriptX -->
<script src="/scripts/jquery.js"></script>
<script
    data-meadco-license="{09df1dc1-cba3-48a8-aebe-ef2f287b51cd}"
    data-meadco-server="http://127.0.0.1:41191" 
    data-meadco-license-path="warehouse"
    data-meadco-license-revision="0"
    src="/scripts/meadco-scriptx.js"></script>

<script type="text/javascript">
function printPage() {
    factory.printing.header = "";
    factory.printing.footer = "";
    factory.printing.paperSize = "A4";
    factory.printing.Print(false); // don't prompt
}
</script>

or, modern code with no external modules/libraries:

<script type="text/javascript">
async function printHtml(strHtml, printerName, pageSettings) {
    try {
        let response = await fetch('http://127.0.0.1:41191/api/v1/printHtml/print'), {
            method: 'POST',
            cache: 'no-cache',
            headers: {
                'Accept': 'application/json',
                'Content-Type': 'application/json',
                'Authorization': 'Basic ' + btoa(evaluationLicenseGUID + ':')
            },
            body: JSON.stringify({
                contentType: 2, // "InnerHtml" - specifies an HTML fragment is to be printed
                content: strHtml, // HTML fragment from page
                device: {
                printerName: printerName
            },
            settings: pageSettings
            })
        });

        response = await handleResponse(response);

        console.log("print started, status: " + response.status);
        console.log(response);
    }
    catch (error) {
        console.error("Error while printing: " + error);
    }
}

(async () => {
    try {
        await applyPrintingLicense(evaluationLicenseGUID);

        const printConfig = await printingDefaults();

        document.getElementById("btn-print").addEventListener("click", async () => {
            await printHtml(document.getElementById("printContent").innerHTML,
                printConfig.device.printerName,
                {
                    header: '',
                    footer: '',
                    page: {
                        units: 2, // mm
                        margins: { top: 12.5, left: 12.5, bottom: 12.5, right: 12.5 }
                    }
                });
        });
    } catch (error) {
        console.error("An error occured:" + error);
    }
})();
</script>

Try the button above to receive a PDF of this page. This example is simple but the margins, the page header (including an image and html content) and footer and the paper orientation have been described in JavaScript. Standard CSS is used to remove some content for the print and layout the content appropriately. Notice that the date and time in the footer is the time right now - the PDF was produced right now, it isn't a canned file.

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 the service 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 options:

  • For Windows PC
  • For On-Premise Devices
  • For Cloud

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.

Each user must install the service on their Windows PC. Content can then be printed from any modern browser or Internet Explorer 11.

Current ScriptX.Add-on client licenses will work with ScriptX.Services for Windows PC and there is a reasonable migration path to update current scripts that work with the Add-on to work with ScriptX.Services for Windows PC.

The on-premise service 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.

The service is frictionless. There is nothing for your users client device to install, but they must have javascript enabled. They may be using any modern browser on any device or Internet Explorer 11 on a Windows PC.

We provide a migration path for all current licensees.

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.

The cloud service is frictionless. There is nothing for your users to install, but they must have javascript enabled. They could be using any modern browser on any internet-connected device, from desktop PC to tablet or smartphone.

This service is available now at no cost but is subject to a fair-use policy. Click here to sign up for your free cloud service acccount.

Technical background

ScriptX.Addon

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:

<!-- MeadCo ScriptX -->
<object id="factory" style="display:none"
  classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814"
  codebase="installers/smsx.cab#Version=8,0,0,56">
</object>
<script type="text/javascript">
function printPage() {
    factory.printing.header = "";
    factory.printing.footer = "";
    factory.printing.paperSize = "A4";
    factory.printing.Print(false); // don't prompt
}
</script>

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.

ScriptX.Services Evolution

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.

Browser support

Supporting customers who have an investment in javascript that works with ScriptX.Add-on for Internet Explorer is very important to us. It will be enough of a challenge to convert HTML content originally authored for IE 7/8 to modern HTML that works in all browsers.

To support customers with current code, we provide a library that implements an emulation of ScriptX.Add-on in javascript  ScriptX.Services Client Library . The library will work with both '.factory' based code and with  MeadCoScriptXJS Library based code.

Our ScriptX.Services client libraries support Internet Explorer 11, 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 earlier versions of Internet Explorer.

Print functions

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 [aka factory.Print()]

To print the page/document means delivering the HTML stream to print from the client device to the server. A javascript module implements capturing the current browser DOM content and then delivers that to the server along with required settings.

A further javascript module implements the behaviour of the ScriptX.Add-on window.factory object, but in javascript. Very familiar looking code can then be written.

  1. Replace the <object id="factory" ... /> element from the ScriptX.Addon with including a javascript module that defines a window.factory object that fully emulates ScriptX.Add-on.

    <script src="/scripts/meadco-core-1.7.1.js"></script>
    <script src="/scripts/meadco-scriptxprint-1.7.1.js"></script>
    <script src="/scripts/meadco-scriptxprinthtml-1.7.1).js"></script>
    <script src="/scripts/meadco-scriptxfactory-1.7.1.js"></script>
    <script src="/scripts/meadco-scriptxprintlicensing-1.7.1.js"></script>
    <script src="/scripts/meadco-secmgr-1.7.1.js"
        data-meadco-license="09df1dc1-cba3-48a8-aebe-ef2f287b51cd"
        data-meadco-license-revision="0"
        data-meadco-license-path="warehouse"
        data-meadco-server="http://127.0.0.1:41191">
    </script>
                
  2. The javascript doesnt change:

    <script type="text/javascript">
    function printPage() {                  
        factory.printing.header = "";
        factory.printing.footer = "";
        factory.printing.paperSize = "A4";
        factory.printing.Print(false); // don't prompt
    }
    </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 [aka factory.PrintHtml()]

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.

Write once

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:

<!-- MeadCo ScriptX -->
<object id="secmgr" style="display:none"
  classid="clsid:5445be81-b796-11d2-b931-002018654e2e"
  codebase="installers/smsx.cab#Version=8,0,0,56">
    <param name="GUID" value="09df1dc1-cba3-48a8-aebe-ef2f287b51cd" />
    <param name="Path" value="sxlic.mlf" />
    <param name="Revision" value="0" />
</object>
<object id="factory" style="display:none"
  classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814"">
</object>
<script src="/scripts/meadco-core-1.7.1.js"></script>
<script src="/scripts/meadco-scriptxprint-1.7.1.js"></script>
<script src="/scripts/meadco-scriptxprinthtml-1.7.1.js"></script>
<script src="/scripts/meadco-scriptxfactory-1.7.1.js"></script>
<script src="/scripts/meadco-scriptxprintlicensing-1.7.1.js"></script>
<script src="/scripts/meadco-secmgr-1.7.1.js"
    data-meadco-license="09df1dc1-cba3-48a8-aebe-ef2f287b51cd"
    data-meadco-license-revision="0"
    data-meadco-license-path="warehouse"
    data-meadco-server="http://127.0.0.1:41191">
</script>
<script type="text/javascript">
function printPage() {
    factory.printing.header = "";
    factory.printing.footer = "";
    factory.printing.paperSize = "A4";
    factory.printing.Print(false); // don't prompt
}
</script>
Modern code

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.

  • plain text headers and footers,
  • margins,
  • landscape or portrait orientation of the paper.
  • choosing the paper size to use,
  • monitoring of job progress,
  • full html headers and footers,
  • advanced print scaling.

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.

Advantages of ScriptX.Services
  •  Modern browser independence; the host browser and device is not used to to print, print occurs at a server.
  •  Consistent output whatever the client browser. A single print engine is used at the server so the results will always be the same.
Disadvantages / Issues
  •  At this time we are using the Internet Explorer 11 Trident Rendering engine in 'edge' mode. This is a highly capabable mode with a high degree of compatibility with modern standards HTML as might be required to be printed but clearly there will be some content that cannot be printed or will appear incorrect if it is not supported by Internet Explorer 11 in standards mode.

  •  At this time, referenced content from a page such as style sheets and images that are inaccessible to the anonymous printing process cannot be obtained and used during printing.

    For example, consider you are using a website behind a firewall (or localhost) and use the Cloud Printing Service. The HTML to print is sent to the service along with style sheet references that are relative to the original document and/or image sources that are relative to the original document. The print service will not be able to access this content. The result is that the html is printed but no style is applied and the images will be missing.

    Similarly, the same problem wil arise when using ScriptX.Services for On Premise Devices or ScriptX.Services for Windows PC and content such as stylesheets and images referenced by the HTML to be printed is protected from anonymous access. This protection may be in the form of authentication, or CORS (for example, browsers perform CORS checking on font .woff files).

    At this time, the workaround for this issue is to allow anonymous access / enable CORS to these resources.

Next up: Getting started - Examples in coding
  • Knowledge Bank
  • 'How To' Guides
    • ScriptX.Add-on
      • Introduction
      • Installing ScriptX on client PCs
      • Basic printing with ScriptX
      • Advanced printing features
      • Backwards compatibility
      • How to check if ScriptX is installed
      • MeadCoScriptXJS Library
      • License deployment
      • Client-side printing samples
    • ScriptX.Services
      • Introduction
      • Getting started
      • Maintaining investment in current code
        • Stage 1: Adding UI
        • Stage 2: Printing with ScriptX.Services
        • Stage 3: Summary and review
        • Stage 4: Error reporting
        • Stage 5: Prompted printing
        • Stage 6: Preparing for advanced uses
        • Stage 7: WaitForSpoolingComplete
        • Stage 8: Recommendations for some common issues
      • MeadCoScriptXJS Library
      • Printing with the API
      • Installing ScriptX.Services
        • For Windows PC v1
        • For On Premise Devices hosted on Windows Server v1
        • For On Premise Devices hosted on Windows 10 v1
        • Cloud
      • Debugging
      • License deployment
        • For Windows PC
        • For On Premise Devices
      • Samples
        • Configure for Windows PC
        • Configure for On Premise
        • Configure for Cloud
    • Security Manager
      • Deploying a license or revision
  • Technical Reference
    • ScriptX.Add-on
      • factory
        • baseUrl
        • ComponentVersionString
        • IsUniqueIDAvailable
        • OnDocumentComplete
        • relativeUrl
        • ResetUniqueID
        • ScriptXVersion
        • SecurityManagerVersion
        • Shutdown
        • UniqueID
      • printing
        • AddPrinterConnection
        • BatchPrintPDF
        • BatchPrintPDFEx
        • bottomMargin
        • collate
        • copies
        • currentPrinter
        • DefaultPrinter
        • disableUI
        • duplex
        • duplex2
        • EnumJobs
        • EnumPrinters
        • footer
        • GetJobsCount
        • GetMarginMeasure
        • header
        • headerFooterFont
        • IsSpooling
        • IsTemplateSupported
        • leftMargin
        • onafterprint
        • onbeforeprint
        • onbeforeunload
        • onpagesetup
        • onuserpagesetup
        • onuserprint
        • onuserprintpreview
        • orientation
        • OwnQueue
        • pageHeight
        • PageSetup
        • pageWidth
        • paperSize
        • paperSource
        • paperSource2
        • portrait
        • Preview
        • Print
        • printBackground
        • printer
        • PrintHTML
        • PrintHTMLEx
        • PrintPDF
        • PrintSetup
        • printToFileName
        • RemovePrinterConnection
        • rightMargin
        • SetMarginMeasure
        • SetPageRange
        • SetPreviewZoom
        • SetPrintScale
        • Sleep
        • templateURL
        • topMargin
        • TotalPrintPages
        • unprintableBottom
        • unprintableLeft
        • unprintableRight
        • unprintableTop
        • WaitForSpoolingComplete
      • printerControl
        • attributes
        • Bins
        • Forms
        • isLocal
        • isNetwork
        • isShared
        • Jobs
        • location
        • name
        • Pause
        • port
        • Purge
        • Resume
        • serverName
        • shareName
        • status
      • Job
        • Delete
        • Pause
        • Restart
        • Resume
      • enhancedFormatting
        • allFooterHeight
        • allHeaderHeight
        • allPagesFooter
        • allPagesHeader
        • extraFirstFooterHeight
        • extraFirstPageFooter
        • firstFooterHeight
        • firstHeaderHeight
        • firstPageFooter
        • firstPageHeader
        • pageRange
        • printingPass
      • rawPrinting
        • printer
        • printDocument
        • printString
    • ScriptX.Services
      • Web service API
        • Service Description
          • (GET)
        • Licensing
          • licensing (GET)
          • licensing (POST)
          • licensing/ping (GET)
        • PrintHtml
          • settings (GET)
          • deviceinfo (GET)
          • htmlPrintDefaults (GET)
          • print (POST)
          • status (GET)
          • download (GET)
          • canceljob (PUT)
        • PrintPdf
          • print (POST)
          • status (GET)
          • download (GET)
        • PrintDirect
          • print (POST)
    • Security Manager
      • How it works
      • License Expiry
      • Testing for a valid license
      • About the license file (.mlf)
        • LICENSE
        • APPLICENSE
        • TITLE
        • DOMAINS
        • DOMAIN
        • PERMISSION
      • API
        • Apply
        • License
        • result
        • validLicense
  • Articles
    • Dialogs with ScriptX.Services
 
© 2025 Mead & Co Limited. Version: 4.2.8-R.20210726.1 | Privacy Policy
© 2025 Mead & Co Limited. v1.0.2
X

Warning:

This ScriptX.Add-on sample can only be viewed using Internet Explorer.