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 ›  ScriptX.Add-on Client-side printing samples

ScriptX.Add-on Client-side printing samples

NOTE

ScriptX.Add-on is for Internet Explorer users only. As you are viewing this page in a different browser clicking any of the links to samples will attempt to show the sample in your browser. The sample MAY NOT work if it is solely intended for use with ScriptX.Add-on.

These samples continually evolve as a result of feedback from customers. Many samples are based on real-world examples of ScriptX usage.

We provide two sets of examples: the first set covers core usage and installation and includes samples for core usage, and the second illustrates advanced usage scenarios.

Introduction

Introduction and Installing ScriptX.Addon

How to install ScriptX

Shows the steps required to install ScriptX. The code from these sample is re-used in all the Basic (free) use samples.

How to deploy an advanced use client license

Discusses client licensing and how to use the license on the page. Samples illustrate the license acceptance dialog users may see and how to handle errors.

Display information on the installed version

This is a useful page to show the version of the each of the main components of ScriptX that are installed on the client PC.

Printing with ScriptX.Services

Print and preview

Illustrates the fundamentals of starting a print preview or print from javascript.

The basic print features

Illustrates the use of many of the basic printing features of ScriptX.

Use cases

Advanced print features

ScriptX offers more than just the basic functionality of promptless document printing. It allows for customization of headers, footers, margins, and page orientation. But what sets it apart are its advanced features. These provide a comprehensive set of tools that cater to the diverse printing needs of developers, making it a versatile solution for any project.

Introduction and overview of advanced features for printing HTML

Provides a summary of the advanced features of ScriptX and shows the use of many advanced features.

Controlling margins, printing and previewing frames

In an international environment there may be a mixture of margin measurement units - this sample sets margins in the opposite units to your default illustrating that with ScriptX you gain control of the units for specifying measurements. This sample also illustrates the scaled to fit preview and printing of a frame.

Controlling printers and print queues

Illustrates the use of the printerControl, Jobs and Job objects.

Working with different standards and document modes

This sample illustrates the support for different document modes by ScriptX and in particular ScriptX 8 in Internet Explorer 11. ScriptX 8 will work well with 'legacy' content when that content uses appropriate document modes either by use of DOCTYPE or Enterprise Modes.

Print to file

An example workflow is for the user to print a customer receipt to a physical printer and the system will also print the same content to a PDF file using PDF output printer driver as an archive.

NOTE: When working with ScriptX.Services v2.11 or later is required.

Performance measures

Various print operations with monitoring and timing to provide performance estimates.

Providing UX/UI

A simple print user interface

It can be useful to provide the user with a targetted user interface rather than rely on all attributes being set in script. This sample illustrates listing the available printers and allowing the user to select the printer to use.

A complete print user interface

It can be useful to provide the user with a targetted user interface rather than rely on all attributes being set in script. This sample implements the Page setup and Print settings dialogs in a single HTML dialog.

Using the WaitForSpoolingComplete function

This sample discusses the use of the ScriptX.Addon WaitForSpoolingComplete() function in a variety of scenarios. Please note that the discussion is different between ScriptX.Add and ScriptX.Services.

Working with iFrames

Frame preview and printing

Introduction to printing and previewing iframes. The core basic samples illustrate printing of a frame but with a license an iframe can also be previewed.

Hosting ScriptX inside an iFrame

We commonly recommend that ScriptX is included in the top most document. However, in some architectures this would mean ScriptX is continually present during the lifetime of an application which may needlessly consume valuable resources on the device. This sample illustrates using ScriptX inside an iframe.

Print "remote" documents

Very often ScriptX is used to print the content of the document as it is displayed on the screen but there can also be a need to print a document downloaded from a server. The document might be static or generated in response to the request for the document.

The PrintHTML() method downloads and prints remote documents in the background.

Queuing many files and monitoring progress

PrintHTML() is a fire and forget method and if anything goes wrong no one will know other than nothing has appeared at the printer. The PrintHTMLEx() method provides for monitoring the progress of the job and notification of errors.

Print a single file and consequences for server session state

Printing a remote document occurs in the background. For ScriptX.Addon this can be in the same process as Internet Explorer or can be an external process. This sample shows the difference. For ScriptX.Services, all printing occurs in a separate process.

Impact of document standards

Printing a remote document occurs by downloading the document, loading to the print engine and then printing it. ScriptX 8 / ScriptX.Services adds support for documents using modern standards but this can have a negative impact on documents relyiong on older behaviour. This sample shows how to resolve these issues if they occur.

Working with client generated html

Very often ScriptX is used to print the content of the document as it is displayed on the screen but there can also be a need to print literal html content that is dynamicaly constructed by javascript code or extracts from the page content.

By using the html:// pseudo protocol, the PrintHTMLEx() method can print snippets of HTML.

These samples also illustrate mixing ScriptX.Add-on and ScriptX Services on the same page. So, the choice of technology will solely be based upon the browser you are using and if ScriptX.Add-on is available. The F12 tools can be used to examine the impact of document modes when using Internet Explorer.

Introduction

An introduction to printing literal html with ScriptX.

Modern content

This sample illustrates the behaviour of ScriptX v8 which fixes a bug that 'modern' html (e.g. rotated elements, modern box rules) could not be printed. Unfortunately the fix can introduce problems with old content. ScriptX 8 attempts to make compatible decisions but if it gets it wrong this shows how to enforce the correct processing for correct output.

Enhanced page layout

Enhanced page layout is the ability to use page headers and footers that use full html markup instead of simply text in a single font and to define the pages to print as more than a single range.

This capability is useful to provide a 'master' page style of working with logos etc. specified in script and the printed document content coming from the current page.

An Enhanced Formatting license is required in addition to a license for Advanced Printing.

HTML headers and footers introduction

A simple example showing the basics of using html markup in headers and footers.

Headers and footers with images and multi-line HTML

There are no limits beyond what HTML can do.

Page ranges

This sample shows the use of enhanced page range specification; the ability to print arbitrary ranges of pages (rather than a single range) and print only odd, only even or both odd and even numbered pages.

Techie *Everything*

An all-in-one sample by which you can explore the effect on output of each of the enhanced formatting options along with all the other options such as margins, the printer to use, orientation etc. This is the ultimate sample!

Printing PDF documents

ScriptX Enhanced PDF Printing provides for printing Adobe Acrobat (PDF) documents with control of the printer, paper etc to be used. Prompted or promptless printing is provided.

An Enhanced PDF Printing license is required in addition to a license for Advanced Printing.

Printing a single file

To synchronously print a single PDF file, use the PrintPDF() API. The url of the PDF document to be printed is specified, the printer to use etc can be chosen by the user by utilising prompted printing.

Printing one or more files in the background

Asynchronous printing of one or more files to the current printer is available with the BatchPrintPDF API. With batch printing, files are downloaded and printed in the background, allowing users to continue with other tasks on the displayed page.

Printing one or more files with more feature control

If scripted control of the printer to use and other features is required when printing one or more documents, then features required are set and the BatchPrintPDF() API used.

Printing one or more files with feature control and progress callbacks

If scripted control of the printer to use and other features is required when printing one or more documents along with progress information then the BatchPrintPDFEx() API used.

Printing a single base64 encoded PDF document

If your work flow requires sending PDF within a text stream such as xhtml or json then you will be generating base64 encoded PDF documents.

By use of a DataUrl, ScriptX can print the document removing the requirement for multiple output formats from your workflow.

NOTE: ScriptX.Addon 8.3.0.4 or ScriptX.Services for Windows PC 2.10.0.16 or ScriptX.Services On Premise 2.10.8.2 (with ScriptX.Server 10.3.0.2 or later) is required.

Printing one or more base64 encoded PDF documents in the background

If a PDF is being dynamically generated at the server it can be delivered as a Base64 encoded string to the browser and then printed by ScriptX using a Data URL to the encoded content.

With batch printing, encoded pdf documents are processed and printed in the background, allowing users to continue with other tasks on the displayed page.

NOTE: ScriptX.Addon 8.3.0.4, or ScriptX.Server 10.3.0.2 or ScriptX.Services for Windows PC 2.10.0.16 or ScriptX.Services On Premise 2.10.8.2 or later is required.

Raw/Direct (labels) printing

Raw or "direct" printing is used to send streams of bytes to the printer without any interpretation. Print commannds and language sequences such as ZPL can be sent to appropriate printers for printing labels etc.

A ZPL compatible printer is required for these samples.

They also require that you are using either ScriptX.Addon or ScriptX.Services for Windows PC or ScriptX.Services for On Premise devices configured to use a suitable printer.

A Direct (RAW) Printing license is required in addition to a license for Advanced Printing.

Printing a simple label with ZPL

For introduction this sample prints a simple label defined by a string of ZPL commands.

Interactive playground

This sample allow you to enter the ZPL/EPL commands to send to your printer

Printing the content from a document/url

Appropriate content may be downloaded from a server and sent to the printer. For example, a work-flow process may have generated the files to print or an API end point may return text. This example demonstrates using file containinng ZPL command sequences.

Working with and printing SVG

Scaling SVG

Uses simple SVG elements to illustrate support for SVG. An issue with SVG is that it can require scale factors outside the default range. ScriptX has solutions for this.

Scaling Framed SVG

As above but the sample content is shown in a frame.

Business charts with no ScriptX

Illustrates the standard behaviour of your device and browser with some SVG charts without ScriptX.

Business charts with ScriptX

Illustrates the control of printing SVG charts with ScriptX.

Miscellaneous use cases

Printing and scaling large images

Inspired by a real world implementation by a customer this sample illustrates scaling a large image to fit the paper.

Duplex printing

Illustrates two sided (duplex) printing with the duplex2 property.

Default printer

The DefaultPrinter() API is deliberately vague in its description. Exactly what is returned depends upon circumstances and it is unwise to depend on a single meaning.

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