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 ›  Then To Now ›  Stage 3

Migration and maintaining investment summary and review

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).

Previously : Stage 2 - Printing with ScriptX.Services

The final document is:

<html>
<head>
<title>MeadCo's ScriptX</title>
</head>
<body>
<!-- MeadCo Security Manager -->
<object id="secmgr" viewastext style="display:none"
  classid="clsid:5445be81-b796-11d2-b931-002018654e2e">
  <param name="GUID" value="09df1dc1-cba3-48a8-aebe-ef2f287b51cd" />
  <param name="PATH" value="https://licenses.meadroid.com/download/{09df1dc1-cba3-48a8-aebe-ef2f287b51cd}/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>
<div style="font:bold 32pt courier new; text-align: justify; letter-spacing: -1px">
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 ... <br><br>
-> -> -></div>
<!-- new UI -->
<div>
<button id="btn-print">Print</button> <button id="btn-preview">Preview</button>
</div>
<!-- scriptx.services requires jquery -->
<script src="https://cdn.jsdelivr.net/npm/jquery@3/dist/jquery.min.js"></script>

<!-- Add.on to scriptx.services compatibility -->
<script src="//cdn.jsdelivr.net/npm/scriptxprint-html@1.7.1/dist/meadco-scriptxservices.min.js"
	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"
	data-meadco-syncinit="true"
>
</script>

<!-- leave current script as is, it will work .. to minimise effort -->
<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 = 1.0
    factory.printing.topMargin = 1.5
    factory.printing.rightMargin = 1.0
    factory.printing.bottomMargin = 1.5
}
</script>

<!-- new UI script -->
<script type="text/javascript">
$(window).on("load",function() {
    initView();
	$("#btn-print").click(function() {
		factory.printing.Print();
	});

	$("#btn-preview").click(function() {
		factory.printing.Preview();
	});
});
</script>
</body>
</html>

If the additions made to provide an on document UI are excluded, a few lines of code have been added to achieve use from anywhere:

<!-- Add.on to scriptx.services compatibility -->
<script src="//cdn.jsdelivr.net/npm/scriptxprint-html@1.7.1/dist/meadco-scriptxservices.min.js"
    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"
	data-meadco-syncinit="true"
>
</script>

And it is arguable that is one line made readable by using several lines.

However, as with the document we started with, there is no error checking, no ensuring that the license is available. The code runs synchronously which is now deprecated and there is no prompt when printing.

Improving the code and starting to deal with these issues will be the subject of the next article.

Next up: Stage 4 - Error reporting.
  • 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.