ScriptX logotype
  • Getting started
  • Documentation
  • Samples
  • Pricing
Free Trial Downloads
  • Home
  • Getting started
  • Documentation
  • Samples
  • Pricing
Developers ›  Knowledge Bank ›  How To Guides ›  ScriptX.Add-on ›  Guide To Client-side Printing ›  Basic Printing With Script X

Basic printing with ScriptX

A basic subset of ScriptX client-side printing functionality -- header & footer settings, printed orientation, coarse control of margins and a browser window/frame printing command -- is available at no charge, and is freely distributable.

The basic printing of an HTML document with ScriptX follows a simple pattern:

  1. Enable 'basic' printing by authoring the MeadCo ScriptX OBJECT tag on the document
  2. Author the required UI, for example a button which when clicked will print the document
  3. 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

How to enable ‘basic’ printing

A ‘basic’ ScriptX-enabled document is defined as one on which the ScriptX object block appears thus:

    
    <!-- MeadCo ScriptX -->
    <object id="factory" style="display:none"
            classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814"
            codebase="http://[your path here]/smsx.cab#Version=8,3,0,4">
    </object>    
    

For successful installation and operation the codebase attribute must ‘point’ to the correct location and version number of the smsx.cab file on your servers. That ‘pointer’ path can be relative to the location of the document on which the ScriptX object appears, or it can be fully qualified.

For more details on installation options, please see Installing ScriptX on Client PCs.

Authoring the UI

Obviously this is entirely dependent on particular application requirements but the essentials are always the same; a document element (such as a button) raises an event in response to a user action (such as a click) and a scripted event handler implements the required actions (such as setting print headers and footers and starting the print).

ScriptX is entirely agnostic about how you develop your scripts, for example, you might wish to use jQuery (as we do in the samples) or some other javascript library. For the purposes of illustration, the example below is old fashioned, but simple!

    
    <button onclick="btn_print_onclick()">Print report</button>
    
Event handling script - formatting printing attributes and printing

A typical function call to set ‘basic’ print formatting and print a top-level document client-side could look like this:


function btn_print_onclick() {
    factory.printing.header = "This is MeadCo";
    factory.printing.footer = "Printing by ScriptX";
    factory.printing.portrait = false;
    factory.printing.leftMargin = 1.0;
    factory.printing.topMargin = 1.0;
    factory.printing.rightMargin = 1.0;
    factory.printing.bottomMargin = 1.0;
    factory.printing.Print(false);
}

Notice that we call all ScriptX functions by reference to the ID of the on-page ScriptX object - usually ‘factory’.

Notes:

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

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