ScriptX logotype
  • Getting started
  • Documentation
  • Samples
  • Pricing
Free Trial Downloads
  • Home
  • Getting started
  • Documentation
  • Samples
  • Pricing
Developers ›  Knowledge Bank ›  How To Guides ›  ScriptX.Services ›  Maintaining investment in current code

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


<html>
<head>
    <title>MeadCo's ScriptX</title>
    <style type="text/css">
        html, body {
            font-family: Segoe,Lucida Grande,Lucida Sans,Verdana,sans-serif;
            margin: 24px;
        }
    </style>
</head>
<body onload="initView()">

<!-- MeadCo Security Manager -->
<!-- NOTE: A codebase would usually be included. -->
<!-- The evaluation GUID is subject to change -->
<object id="secmgr" viewastext style="display:none"
    classid="clsid:5445be81-b796-11d2-b931-002018654e2e">
    <param name="GUID" value="{8f351de0-5990-45c3-8fd2-8037b878939f}" />
    <param name="PATH" value="https://licenses.meadroid.com/download/{8f351de0-5990-45c3-8fd2-8037b878939f}/mlf" />
    <param name="REVISION" value="0" />
    <param name="PerUser" value="true">
</object>

<!-- MeadCo ScriptX -->
<object viewastext id="factory" style="display:none"
    classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814">
</object>

<script>
function initView() {
    // WARNING: use of .enhancedFormatting requires a license with Enhanced Formatting enabled.
    factory.printing.enhancedFormatting.allPagesHeader =
    "<div><center><img src='http://services.meadroid.com/images/sx-header.png'></center></div>";
    factory.printing.enhancedFormatting.allPagesFooter =
    "<div><center><img src='http://services.meadroid.com/images/sx-footer-final.png'></center></div>";
    // Remove the above two lines if testing with a license without Enhanced Formatting enabled.
    factory.printing.SetMarginMeasure(2) // set inches
    factory.printing.header = ""
    factory.printing.footer = ""
    factory.printing.leftMargin = 0.75
    factory.printing.topMargin = 1.5
    factory.printing.rightMargin = 0.75
    factory.printing.bottomMargin = 1.5
}
</script>

<h1>MeadCo's ScriptX.Addon</h1>

<div style="font-size: 14pt; line-height: 22pt;">
    For nearly 20 years MeadCo's ScriptX - now installed on many millions of Windows PCs - has
    enabled document authors to script print-time attributes such as margin sizes, orientation,
    HTML & standard headers and footers, paper source, target printer, prompt-free printing and much more ...
</div >
</body>
</html>

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
  • Knowledge Bank
  • 'How To' Guides
    • ScriptX.Services
      • Introduction
      • Getting started
      • Evaluate with modern code
      • 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
      • Printing with the API
      • MeadCoScriptXJS Library
      • Installing ScriptX.Services
        • For Windows PC
        • For On Premise Devices hosted on Windows Server
        • For On Premise Devices hosted on Windows 10/11
        • Configure options For On Premise Devices
        • Cloud
      • Orchestrator
      • 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
    • 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
      • License deployment
      • Quick start with Visual Studio
        • ASP.NET MVC
        • ASP.NET Web Forms
      • Nuget Packages
        • MeadCoScriptXJS Library
        • Installer helpers
        • ASP.NET WebForms Controls
        • Helpers for ASP.NET MVC
      • Client-side printing samples
  • Technical Reference
    • ScriptX.Services
      • Web service API
        • Service Description
          • (GET)
        • Licensing
          • licensing (GET)
          • licensing (POST)
          • licensing/ping (GET)
        • Printer
          • settings (GET)
          • current (GET)
          • current (PUT)
          • connection (PUT)
          • connection (DELETE)
        • 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)
      • Orchestrator API
        • v1
          • GET
        • v2
          • PUT
          • GET
      • ScriptX.Services compatibility roadmap
    • 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
    • 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
    • Change and history logs
    • Articles
      • v1.15.x ScriptX Client Library
      • Dialogs with ScriptX.Services
      • Accessing protected content
      • Long term servicing (LTS)
 
ScriptX logotype
Home Getting started Documentation Samples Contact us

© 2025 Mead & Co Limited.

Follow us:
LinkedIn   GitHub
X

Warning:

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