A stage by stage walkthrough

A walk through developing a single source that supports both ScriptX.Add-on and ScriptX.Services. The code used in the sample can be used in your own projects. This sample set is a reference for when things go wrong.

These samples can be viewed in IE 11 - in which case the Add-on will be used. Or any evergreen browser, in which case ScriptX.Services will be used.

Note that if even if you have chosen to use ScriptX.Services with Internet Explorer 11 in settings, Internet Explorer will only use ScriptX.Addon in this samples set.

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.

Providing UX/UI

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.

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.

This sample discusses the use of the WaitForSpoolingComplete() function emulation with ScriptX.Services in a variety of scenarios.

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.

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.

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.

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.

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

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.

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.

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.

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.

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.

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.

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.