05.JSP2012. 4. 9. 11:35
반응형

ScriptX printing: technical manual

January 2011 (Version 6.6 and later)


Contents

Overview
Introduction
Summary of examples
Advanced Control of HTML Printing with ScriptX
Technical support
How do I use ScriptX?
Client-side (within Internet Explorer)
Basic functionality: smsx.cab
Advanced functionality: smsx.cab
How to check whether or not the object is properly installed
Testing your print-outs
Server-side deployment
Within a desktop application
Reference

Overview

Introduction

MeadCo's ScriptX is a suite of ActiveX technology components designed to provide absolute control over document printing operations from client and server computers running the Microsoft Windows Web Browsing Platform.

Part of its purpose is to ensure the consistent formatting and appearance of printed output from any local or networked printer, regardless of the printing attributes already set in that computer's Internet Explorer (IE) browser. ScriptX applies a document author's desired attributes at the time of printing browser window or framed content, but thereafter automatically restores all default settings and makes no permanent changes.

ScriptX 1.0 was introduced by MeadCo in 1998 as a freely distributable utility offering a limited set of print formatting functionality - the scripted control of the printing of HTML frame or window content (with or without a prompt), and the specification by script of printing parameters such as page headersfootersmarginsand paper orientation within IE.

That basic functionality is still available at no charge and is freely distributable. Features that are part of that 'free' printing subset are marked in this document asbasic.

With the releases of later versions, significantly more advanced printing functionality was introduced which is only accessible in the presence of a paid-for MeadCopublishing license.

Target platform

ScriptX has been tested on and supports Microsoft Windows Web Browsing Platform versions 4.01 SP1 - 7.0 on all Microsoft Windows Win32 OS platforms (including Vista).

ScriptX v6.4 and later no longer support Windows 9x/NT. For maintenance support of these operating systems, please see ScriptX win9xNT/NT Maintainance Mode Binaries.

ScriptX v6.4 and later are supported on all Microsoft Windows client and server platforms from Windows 2000 onwards with Internet Explorer 5.5 or later.

Product credits

ScriptX has been widely adopted and acknowledged by the Web and intranet development communities. Check out:

Summary of examples

    Basic
    Illustrates the straightforward use of the freely distributable ScriptX basic printing functionality: headersfootersmargins and paper orientation.

    Advanced
    Illustrates the typical use of ScriptX advanced printing functionality for which a publishing license is required.

    Techie
    An all-in-one technical example illustrating the most advanced use of licensed ScriptX functionality.
    Printing reports and customised documents
    Provides a discussion of printing customised documents and reports with ScriptX and a number of samples of differing techniques. A download of all the sample code is included.
    Direct printing
    Illustrates direct printing to a Zebra thermal label printer using the ZBL command language, a publishing license is required.

Feel free to investigate the source code from any of the examples and to cut & paste fragments into your own applications.

Advanced control of HTML Printing with ScriptX

Advanced printing functionality can only be used with a paid-for publishing license. Some of the advanced features enabled with a license are:

  • Control over the printing of a document's background color and images (printBackground).

  • SetMarginMeasure method to ensure that the chosen unit of measure for margins (inches or millimeters) will be consistent across machines with different locale settings.

  • Facilities to select a non-default printer, paper size & source, page range & collation and number of copies to print.

  • Reliability and scalability. The PrintHTML(url) method can queue and print any number of documents without compromising system performance. This is especially important for server side printing. On the client side, PrintHTML works in the HTTP session context of the calling page (SSL is supported as well).

  • Precise tracking of spooler activity (IsSpoolingWaitForSpoolingCompleteonafterprint). By default, when the Internet Explorer window is closed or the page navigated away from whilst a print-out is still being spooled, the user will be prompted. The prompt can be customized or disabled (onbeforeunload).

  • Print settings changes (headersbasicfootersbasicmarginsbasicpaper orientationbasicprinter namepaper sizepaper sourcepage range selectionnumber of copiescollationduplex mode) once made from script now become active for Internet Explorer's native UI Print... and Page Setup... commands, as well as for the native window.print() script method, during the time that the document is displayed. Now an author doesn't need to put a [Print] button on an HTML page.

  • Internet Explorer's native printing UI can be trapped and cancelled, or handled in a particular way (disableUIonuserprintonuserpreviewonuserpagesetup). A document's DHTML user interface can also be updated in response to user changes in the Page Setup and Print dialogs (onpagesetup). See the Techie printing example for an illustration of UI handling.

  • All changes made to print settings affect only the current document (in the current tab) when it is printed or previewed. Settings are untouched in other IE windows or tabs and will not apply to any other documents viewed in the current window/tab.

  • A redirect of print data can be made to a specified file name (printToFileName).

  • Basic printing of Microsoft Officetm documents.

  • Printing of PDF documents (PrintPDF and BatchPrintPDF).

Backwards compatibility

All releases of ScriptX are fully backwards compatible with previous releases and for advanced functionality will work with all existing publishing licenses. ScriptX works in close concert with the Microsoft Windows Web Browsing Platform and as a result  is updated to work with all latest releases and patches. All code updates are free; there is never a charge for obtaining the latest code.

We strongly recommend that you update your <OBJECT> elements to reference the current version 7,0,0,8 and update smsx.cab on your servers.

  • An important compatibility issue is that ScriptX printing will always prompt when called in the context of Internet Explorer's Internet Security Zone (check the zone icon in the browser's status bar). This is done to prevent anonymous Internet content invoking printing without a prompt (see PRB: Printing with WebBrowser from Internet Explorer Raises Print Dialog Box in Internet Explorer 5).

    For the My Computer, Local Intranet and Trusted Sites Security Zones promptless printing will work. If you need promptless printing for the Internet Security Zone, you should obtain a publishing license that will bind the deployment of ScriptX to the URL addresses from which you want to serve ScriptX-enabled content.

  • Another important note concerns margin units of measure (inches and millimeters). By default ScriptX uses the units of measure set on the client machine. This is OK when pages are being authored for a known environment such as a small corporate intranet where all Regional Settings are identical, but in a broader environment users' Number settings are certain to vary. So an author should specify the SetMarginMeasure method with a value of either 1 (mm) or 2 (inches). ScriptX will then print to the margins specified regardless of -- and without affecting -- a user's default Regional Number Settings.

What's New Summary

A full listing of the release of ScriptX versions and the modifications they contained is available on the ScriptX History page.

v6.2

Version 6.2 introduces the printerControlJobs and Job objects to provide detailed information about the available printers and control of the print queue for a printer. The use of methods that control the print queue requires that the user has administrator rights on the printer.

Also included in this version is an extension of the MeadCo licensing scheme to provide a usable distribution model and allow the use of ScriptX within desktop applications.

v6.3

Version 6.3 provides support for Internet Explorer 7 on Windows XP and Windows Vista; v6.3 is required on the IE 7 platform ... previous versions of ScriptX arenot compatible.

This release includes a new print template that provides the same functionality as that within Internet Explorer 7 - scale to fit printing by default and enhanced print preview with draggable margins and switchable headers. This template is available for all versions of Internet Explorer from v5.5 so, whilst your users may be running anything from IE 5.5 onwards, you can give them all a consistent print experience.

The use of the new template is optional - by default ScriptX will use the default template for the platform (IE5.5 style on IE 5.5/IE 6 and IE 7 style on IE7. The particular template required can be specified in script using the templateUrl property or may be specified as a parameter to the ScriptX object.

Frames can now be previewed. This was a MaxiPT only feature but is now also included in the Advanced licensed feature set for ScriptX.

A code review has been undertaken with this release, with APIs checked for behaviour and consistency. This has resulted in some cases where in previous releases a property/method would not report an error when an error occurred - errors are now reported. This may necessitate changes to script code if it was assumed that code would run without error.

v6.3.435

From the first build of this version onwards, ScriptX comes in a single signed CAB - smsx.cab. In addition to fixes for a number of issues, this release introduces improvements for application licenses and the ability to install license updates without requesting permission from the user (this will only occur for updates of an already accepted license).

Two new methods are introduced to provide additional control over the behaviour of the new IE 7 style template. These methods require a publishing license:

  • SetPreviewZoom -  provides control over the zoom factor used on print preview.
  • SetPrintScale -  provides control over the scaling used when printing.

v6.3.436

Version 6,3,436 introduces the ability to send raw text to an attached printer. The text is not rendered to the printer, it is interpreted by the printer. This is useful in scenarios such as controlling a thermal label printer. For more information, see rawPrinting.

v6.4

ScriptX v6.4 and later no longer support Windows 9x/NT. For maintenance support of these operating systems, please see ScriptX win9xNT/NT Maintainance Mode Binaries.

This release also introduces Enterprise+ licensing and preliminary support for IE8. Please note that this release has been tested against IE 8 Beta 1 only, there are no known problems other than under Vista where there are a number of small issues which will be addressed in future releases of IE/ScriptX.

v6.5

ScriptX v6.5 and later fully supports IE8 on all supported platforms (Windows 2000 and later). ScriptX 6.5 is a required upgrade for correct operation with IE8.

In support of IE8 one new property has been added: headerFooterFont. Note that scale to fit and print background colours functionality was already included with ScriptX.

A number of problems have also been resolved, including an issue with the SetPageRange() method. Our documentation has been updated to better describe its behaviour. A development history - as well as latest test version of ScriptX - is available on the ScriptX beta page.

v6.6

ScriptX v6.6 introduces a 64-bit Edition for x64 systems and controlled printing of PDF documents with the licensed Corporate 32-bit Edition of ScriptX. ScriptX v6.6 also includes support for Internet Explorer 9 Beta 1 and IE 9 Preview up to Preview 7.

ScriptX 6.6 is a required upgrade for correct operation with IE9.

How do I use the ScriptX object?

Before reading further, please have a look at our illustrative BasicAdvanced and Techie examples of ScriptX printing to get an idea of what ScriptX can do for you.

There are three scenarios in which ScriptX provides the solution for printing of HTML documents with the Microsoft Windows Web Browsing Platform:

  1. Within the Internet Explorer browser, on client-side HTML or XML pages. Here, ScriptX provides full scripted control of the printing experience within IE, allowing choosing the output printer, orientation, page header and footers etc and the initiation of the print. ScriptX is ideal for deployment within web applications hosted within Internet Explorer.
  2. On the server, where ScriptX performs as part of server side request processing, printing an html document loaded from the same or different server.
  3. As part of a desktop application, ScriptX can be used to print HTML documents from the file system, a web server or generated as an 'inline' string.

Note that the use of ScriptX on the server always requires a license. All licenses are available (on request to feedback@meadroid.com) for a trial period to enable full and proper evaluation of the suitability of ScriptX for a particular usage.

Client-side deployment within Internet Explorer (x86 32-Bit Edition).

Typically ScriptX is deployed as a client-side ActiveX control, instantiated and scripted on an HTML or XML page as an <OBJECT> element. Download and installation is a one-time client-side event and is handled automatically by the standard Internet Explorer Component Download technology.

Requirements for a successful installation

  • The end user's system must have the "Download Signed ActiveX Controls" and "Script ActiveX control marked as safe for scripting" security settings enabled for the corresponding Security Zone. These are the default settings for the My ComputerLocal IntranetTrusted Sites and Internet Security Zones.
  • In addition, on Windows 2000 systems and later, the user must be logged on as an Administrator/Power User with the ability to write to the HKEY_LOCAL_MACHINE registry hive and the Windows system folder (typically c:\windows\system32). For Windows Vista and later, the user must be able to complete an Account Control elevation dialog, either through accepting the dialog since they are logged in as an administrator or by entering the user name and password of a suitable administrators account.

Alternative installers (and 64-bit Edition of ScriptX)

If the above requirements cannot be met we suggest that you ask to review our Corporate Resource Kit, a $500-per-year cost-option for licensees which comes as a collection of .msi and merge modules and documentation. The Corporate Kit enables more modern and flexible installation choices than can be provided from our historic .cab-based schema, including the ability to develop a custom installer to requirement using the supplied merge modules.

In addition, the Corporate Resource kit includes the 64 bit Edition of ScriptX. Whilst primarily intended for deployment on server systems for server side printing, the 64 bit Edition can be deployed for use with the 64 bit Edition of Internet Explorer. Please note that, at the time of writing, the default edition of Internet Explorer is 32 bit on all Microsoft Windows operating systems, including 64 bit OSs.

Codebase referencing and use of the object

From the first 6,3,435,x version onwards, ScriptX comes as standard in a single signed CAB - smsx.cab - which is part of a download package obtainable from theScriptX site. The CAB file should be placed on the web server and its location should be referenced by the CODEBASE attribute of the <OBJECT> tag, as shown below.

NOTE: In your own code, we recommend that you place the ScriptX <OBJECT> elements in the document's <BODY> container.

  • Make sure that you provide the correct relative or fully-qualified path to the CAB file and the correct version info (7,0,0,8) in your CODEBASE attributes.

  • Start to script the ScriptX object only when the page is fully loaded i.e. once the window.onload event has occured.

  • Use the defer attribute where appropriate in your scripts: <SCRIPT defer>...<SCRIPT> and avoid immediate script statements (i.e. code which is outside of any function scope). This is an under-appreciated but very useful feature which instructs the script to execute only when the whole document's DHTML content is completely parsed. This way you can be sure of accessing every element on the page.

  • The 'de-facto' standard, 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.

The following code snippets assumes that smsx.cab exists in the same folder as the hosting page itself.

Basic functionality:

<object id="factory" viewastext style="display:none"
classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814"
  codebase="smsx.cab#Version=7,0,0,8">
</object>

The Basic printing example illustrates the use of the basic printing subset.

The viewastext attribute prevents an authoring tool such as Microsoft FrontPagetm or Visual InterDevtm from running the object at design time. This attribute is not required if you do not use these tools and note that it can cause problems in some environments; for example strict xhtml documents.

NOTE: with the 'basic' subset, you can only script headerfooterpage marginspaper orientationPrint and PageSetup methods and properties.

Specifying a template (e.g. IE 7)

With version 6.3 and later, you may specify the template to use; this is particularly useful when wishing to provide the Internet Explorer style template (default scaled to fit printing) to users with IE 5.5/6.0 browsers or when specifying the use of the MaxiPT template.

<object id="factory" viewastext style="display:none"
classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814"
  codebase="smsx.cab#Version=7,0,0,8">
	<param name="template" value="MeadCo://IE7" />
</object>

The ability to specify a particular in-built template is included in the 'basic' subset.

Advanced functionality:

<!-- MeadCo Security Manager -->
<object viewastext style="display:none"
  classid="clsid:5445be81-b796-11d2-b931-002018654e2e"
  codebase="smsx.cab#Version=7,0,0,8">
  <param name="GUID" value="{0ADB2135-6917-470B-B615-330DB4AE3701}">
  <param name="Path" value="sxlic.mlf">
  <param name="Revision" value="0">
</object>

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

NOTE: the {0ADB2135-6917-470B-B615-330DB4AE3701} value of the GUID parameter used above identifies the MeadCo evaluation license that authors may use to experiment with Advanced printing capabilities. The license validates local filesystem (file://) and local website (http://localhost/) content for evaluation purposes only on a single development computer.

The evaluation license is periodic. It will expire in a few months and will be replaced by a new one with a different GUID, so any code depending on the evaluation license may suddenly stop working at any time.

Registered customers are issued with an unique license identifier and a digitally signed sxlic.mlf license file. See the licensing page for more details.

Check out the sources of the Advanced and Techie printing examples for a complete illustration of how to use licensed ScriptX functionality. The following JScript code snippet shows how to modify printing settings so as to print to a specific printer:

<script defer>
function SetPrintSettings() {
  // -- advanced features
  factory.printing.SetMarginMeasure(2); // measure margins in inches
  factory.printing.printer = "HP DeskJet 870C";
  factory.printing.paperSize = "A4";
  factory.printing.paperSource = "Manual feed";
  factory.printing.collate = true;
  factory.printing.copies = 2;
  factory.printing.SetPageRange(false, 1, 3); // need pages from 1 to 3

  // -- basic features
  factory.printing.header = "This is MeadCo";
  factory.printing.footer = "Advanced 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;
}

function Print(frame) {
  factory.printing.Print(true, frame) // print with prompt
}
</script>

A subtle JScript syntax issue may occur when setting a printer name that contains back slashes. Don't forget to double the slashes:

factory.printing.printer = "\\\\FS-LYS-01\\HP5n-759" // print to \\FS-LYS-01\HP5n-759

How to check whether or not the object is properly installed

Upon the window.onload event, test whether or not the object property of the ScriptX or the Security Manager object returns as a valid object. The way to do that is shown in the script snippet below.

In the event that you experience any problems with automatic client-side download and installation, check out HOWTO: Find More Information About Why Code Download Failed and Description of Internet Explorer Security Zones Registry Entries as part of your troubleshooting.

<!-- MeadCo Security Manager - using the evaluation license -->
<object id="secmgr" viewastext style="display:none"
classid="clsid:5445be81-b796-11d2-b931-002018654e2e"
codebase="smsx.cab#Version=7,0,0,8">
  <param name="GUID" value="{0ADB2135-6917-470B-B615-330DB4AE3701}">
  <param name="Path" value="sxlic.mlf">
  <param name="Revision" value="0">
</object>

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

<script defer>
function window.onload() {
  if ( !factory.object ) {
    alert("MeadCo's ScriptX Control is not properly installed!");
    navigate("scriptx-install-error.htm");
    return;
  }
  if ( !secmgr.object ) {
    alert("MeadCo's Security Manager Control is not properly installed!");
    navigate("secmgr-install-error.htm");
    return;
  }
  if ( !secmgr.validLicense ) {
    alert("The MeadCo Publishing License is invalid or has been declined by the user!");
    navigate("license-error.htm");
    return;
  }
  alert("Ready to script MeadCo's ScriptX!")
}
</script>

Testing your print-outs

The development and testing of code to produce good-looking printed reports usually takes a number of iterations. To save toner, paper, trees and our own precious time :-) we regularly use the FinePrinttm application from FinePrint Software.

FinePrinttm installs a virtual printer driver that serves as indirection layer between the printing application (Internet Explorer in our case) and a physical or networked printer. In 'bypass' mode it lets us accurately preview and repaginate ScriptX-enabled content before it is actually printed or discarded.

It's also a very handy testing device with which to diagnose printing problems. So because we are physically unable to test ScriptX with every model and version of printer and printer driver that exists in the world, we would greatly appreciate it if you would try printing to the FinePrint driver before reporting errors against ScriptX from your particular printing environment.

NOTE: Mead & Co Limited has no commercial affiliation with FinePrint Software, LLC.

Working with Visual Studio and ASP.NET

The samples on this site are implemented using ASP.NET and the MVC extensions. The samples system is used in various locations, including the Infopages where the latest release, hotfixes and development versions of ScriptX may be obtained. The samples system itself provides a compreshensive set of demonstrations of the capabilities and working of ScriptX under all document types and modes.

When working with ASP.NET we recommend creating a server-side control or for MVC a partial view that will outout the various object tags required by ScriptX. We recommend values such as codebase location and version are obtained from AppSettings stored in web.config.

Please note that when working with ASP.NET Forms we recommend that the ScritpX objects are placed outside the <form /> element.

Technical support

Licensees of ScriptX' advanced printing functionality are entitled to unlimited direct-to-company email support and access to new versions of the ScriptX software as-and-when issued, both at no additional charge.

Please send us feedback & bug reports.

Web support links

Microsoft Internet Explorer printing and Internet Explorer Component Download support articles:

INFO: WebCast: How Does Internet Component Download Work?

HOWTO: Find More Information About Why Code Download Failed

PRB: Trust Provider Warning Message Appears When You Attempt to Download Components

PROBLEM: Blank Page Is Printed in Internet Explorer 5.5

General information on Internet Explorer printing:

Beyond Print Preview: Print Customization for Internet Explorer 5.5

Print Preview 2: The Continuing Adventures of Internet Explorer 5.5 Print Customization

Print Template Reference

Style Sheets and Printing횂쨩

Inside Technique : Printing Techniques횂쨩

Printing Tables on Multiple Pages

INFO: Page Break Styles Supported Only with Block Elements


ScriptX printing: technical reference

Unless otherwise indicated by the basic icon, the use of any property or method requires a publishing license.

Objects

BinsFormsfactoryprintingprinterControlJobsJobrawPrinting

Properties

attributesbottomMargincollatecopiescurrentPrinterdisableUIduplexfooterheaderheaderFooterFontisLocalisNetworkisSharedJobsleftMargin,locationnameonafterprintonbeforeunloadonpagesetuponuserpagesetuponuserprintonuserprintpreviewpageHeightpageWidthpaperSizepaperSource,port,  portraitprintBackgroundprinterprinter (direct printing), printerControlprintToFileNamerightMarginserverNameshareNamestatustemplateURL,topMarginunprintableBottomunprintableLeftunprintableRightunprintableTop

Methods and Functions

BatchPrintPDFDeleteDefaultPrinterEnumJobsEnumPrintersGetJobsCountGetMarginMeasureIsSpoolingIsTemplateSupportedOwnQueuePageSetup,PausePreviewPrintPrintDocumentPrintHTMLPrintPDFPrintSetupPrintStringPurgeRestartResumeSetMarginMeasureSetPageRangeSetPrintScale,SetPreviewZoomSleepWaitForSpoolingComplete

Objects

Bins


Description

Lists the available paper sources for a printer. The object is a collection (it can be passed to the JScript Enumerator method or used in a VBScriptfor..each loop).

The names returned are suitable for use with the paperSource property.

Syntax

oJobs = printerControl.Bins

Properties

Item(nIndex) - returns the name of the paper source item at nIndex
Count - returns the number of available paper sources.

Methods

None.

Example

<script defer>
function listBins() {
	var j = factory.printing.printerControl(factory.printing.DefaultPrinter()).Bins;
	var e = new Enumerator(j);
	var s = "";
	while ( !e.atEnd() ) {
		if ( s.length > 0 ) s+="\n";
		s += e.item(0);
		e.moveNext();
	}
	alert("There are " + j.Count + " available sources:\n\n" + s);
}
<script>

Applies To

printerControl

See Also

paperSource

Forms


Description

Lists the available paper sizes (forms) for a printer. The object is a collection (it can be passed to the JScript Enumerator method or used in a VBScriptfor..each loop).

The names returned are suitable for use with the paperSize property.

Syntax

oJobs = printerControl.Forms

Properties

Item(nIndex) - returns the name of the paper at nIndex
Count - returns the number of available paper sizes.

Methods

None.

Example

<script defer>
function listForms() {
	var j = factory.printing.printerControl(factory.printing.DefaultPrinter()).Forms;
	var e = new Enumerator(j);
	var s = "";
	while ( !e.atEnd() ) {
		if ( s.length > 0 ) s+="\n";
		s += e.item(0);
		e.moveNext();
	}
	alert("There are " + j.Count + " available paper sizes:\n\n" + s);
}
<script>

Applies To

printerControl

See Also

paperSize

factory


Description

Represents the ScriptX object itself on an HTML page for scripting by its id . For historical reasons, we name it factory.

For WSH or ASP (i.e. server-side) use only, create a ScriptX instance dynamically with the JScript new ActiveXObject횂쨩 or the VBScript CreateObject횂쨩.

Note that you can not use CreateObject or new ActiveXObject to call ScriptX client-side. You should call ScriptX in all client-side cases by the id of the on-page ScriptX object.

See How do I use the ScriptX object for deployment details.

Examples

HTML page:

<object id=factory viewastext style="display:none"
classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814"
codebase="smsx.cab#Version=7,0,0,8">
</object>

WSH script (JScript):

var factory = new ActiveXObject("ScriptX.Factory")
factory.printing.PrintHTML("http://msdn.microsoft.com/workshop/author/script/dhtmlprint.asp")

ASP page (VBScript):

<%
 set factory = CreateObject("ScriptX.Factory")
 factory.printing.PrintHTML "http://localhost/orders/order.asp?number=" & Request.Form("number")
 set factory = nothing
%>

Properties

printingrawPrinting

printing


Description

Represents the printing functionality of ScriptX. See HTML Printing with ScriptX for more information and examples.

Syntax

printing = factory.printing

Properties

bottomMargincollatecopiescurrentPrinterdisableUIduplexfooterheaderheaderFooterFontleftMarginonafterprintonbeforeunload,onpagesetuponuserpagesetuponuserprintonuserprintpreviewpageHeightpageWidthpaperSizepaperSourceportraitprintBackgroundprinter,printToFileNamerightMargintemplateURLtopMarginunprintableBottomunprintableLeftunprintableRightunprintableTop

Methods

BatchPrintPDFDefaultPrinterDoPrintEnumJobsEnumPrintersGetJobsCountGetMarginMeasureIsSpoolingIsTemplateSupportedOwnQueue,PageSetupPreviewPrintPrintHTMLPrintPDFPrintSetupPrintXMLSetMarginMeasureSetPageRangeSetPrintScaleSetPreviewZoomSleep,WaitForSpoolingComplete

Applies To

factory

printerControl


Description

Represents the ability to determine a range of printer properties and control the print queue for the printer. Only the exact printer name strings as they appear on Internet Explorer's Print dialog can be specified. If the string does not exist or is written incorrectly then an error will be thrown (e.g. "The printer name is invalid").

Syntax

oControl = factory.printing.printerControl(sPrinterName)

Properties

attributesBinsFormsisLocalisNetworkisSharedJobslocationnameport,  serverNameshareNamestatus

Methods

PausePurgeRestartResume

Example

<script defer>
function networkServer() {
	var oControl = factory.printing.printerControl(factory.printing.currentPrinter);
	if ( oControl.isNetwork )
		alert("The current printer is on the network server: " + oControl.serverName);
}
<script>

Applies To

printing

rawPrinting (v6.3.436 and later)


Description

Represents the direct printing from within Internet Explorer functionality of ScriptX. Version 6.3.436 or later of ScriptX is required.

Note: Direct printing is a cost-option which can be enabled on a 'standard' client-side license for an additional fee of $500.

Direct printing allows for printing to programmable devices such as thermal label printers, whereby a label string can be sent directly to the printer. The Internet Explorer print engine is not used and takes no part in the process. The functionality available from rawPrinting is completely separate from that available from the printing object, and for this reason settings such as printerpaper sizeorientation, etc. that may have been set on the printing object for Internet Explorer do not apply to the rawPrinting object.

NOTE: rawPrinting is not supported in any form of usage outside of Internet Explorer.

Syntax

raw = factory.rawPrinting

Properties

printer

Methods

printStringprintDocument

Applies To

factory

Jobs


Description

Represents the list of jobs currently in the queue for a printer. The object is a collection (it can be passed to the JScript Enumerator method or used in a VBScript for..each loop).

Syntax

oJobs = printerControl.Jobs

Properties

Item(nIndex) - returns a printJob object for the item at nIndex
Count - returns the number of items in the queue.

Methods

None.

Example

<script defer>
function listJobs() {
	var j = factory.printing.printerControl(factory.printing.DefaultPrinter()).Jobs;
	var e = new Enumerator(j);
	alert("There are " + j.Count + " jobs in the queue");
	while ( !e.atEnd() ) {
		alert("Job name: " + e.item().document);
		e.moveNext();
	}
}
<script>

Applies To

printerControl

See Also

EnumJobsGetJobsCount

Job


Description

Represents a single job in the queue for a printer. A job is obtained from the list of print jobs available on a printer.

Syntax

oJob = printerControl.Jobs.Item(nIndex)

Properties

All properties are read only:

PropertyDescripion
documentSpecifies the name of the print job, typically the title of the html document that has been printed.
machineNameSpecifies the name of the machine that created the print job.
pagesPrintedSpecifies the number of pages that have printed. This value may be zero if the print job does not contain page delimiting information.
positionSpecifies the job's position in the print queue.
printerNameSpecifies the name of the printer for which the job is spooled.
sizeSpecifies the size, in bytes, of the job.
statusSpecifies the job status, can be one or more of the following values:
MeaningValue
JOB_STATUS_PAUSED0x00000001
JOB_STATUS_ERROR0x00000002
JOB_STATUS_DELETING0x00000004
JOB_STATUS_SPOOLING0x00000008
JOB_STATUS_PRINTING0x00000010
JOB_STATUS_OFFLINE0x00000020
JOB_STATUS_PAPEROUT0x00000040
JOB_STATUS_PRINTED0x00000080
JOB_STATUS_DELETED0x00000100
JOB_STATUS_BLOCKED_DEVQ0x00000200
JOB_STATUS_USER_INTERVENTION0x00000400
JOB_STATUS_RESTART0x00000800
statusTextA string containing a description of the status. This may be provided by the printer driver or may be generated by ScriptX from the value of status. If generated by ScriptX the description is in English only.
submittedAtSpecifies the time when the job was submitted.
totalPagesSpecifies the number of pages required for the job. This value may be zero if the print job does not contain page delimiting information.
userNameSpecifies the name of the user who owns the print job.

The value of all properties are determined at the time that the Jobs collection is created, no properties are dynamic (for example a loop inspecting the value of pagesPrinted will not see the value decrease as might be expected).

Methods

DeletePauseRestartResume

Properties

attributes


Description

Returns the attributes of the printer; can be any reasonable combination of the following values:

ValueMeaning
PRINTER_ATTRIBUTE_DEFAULT (0x00000004)Windows 95/98/Me: Indicates the printer is the default printer in the system.
PRINTER_ATTRIBUTE_DIRECT (0x00000002)Job is sent directly to the printer (it is not spooled).
PRINTER_ATTRIBUTE_DO_COMPLETE_FIRST (0x00000200)If set and printer is set for print-while-spooling, any jobs that have completed spooling are scheduled to print before jobs that have not completed spooling.
PRINTER_ATTRIBUTE_ENABLE_BIDI (0x00000800)Windows 95/98/Me: Indicates whether bi-directional communications are enabled for the printer.
PRINTER_ATTRIBUTE_FAX (0x00004000)Windows XP: If set, printer is a fax printer. 
PRINTER_ATTRIBUTE_KEEPPRINTEDJOBS (0x00000100)If set, jobs are kept after they are printed. If unset, jobs are deleted.
PRINTER_ATTRIBUTE_QUEUED (0x00000001)If set, the printer spools and starts printing after the last page is spooled. If not set and PRINTER_ATTRIBUTE_DIRECT is not set, the printer spools and prints while spooling.
PRINTER_ATTRIBUTE_SHARED (0x00000008)Printer is shared.
PRINTER_ATTRIBUTE_WORK_OFFLINE (0x00000400)Windows 95/98/Me: Indicates whether the printer is currently connected. If the printer is not currently connected, print jobs will continue to spool.
PRINTER_ATTRIBUTE_PUBLISHED (0x00002000)Windows 2000/XP: Indicates whether the printer is published in the directory service.
PRINTER_ATTRIBUTE_NETWORK (0x00000010)Printer is a network printer connection.
PRINTER_ATTRIBUTE_LOCAL (0x00000040)Printer is a local printer.
PRINTER_ATTRIBUTE_RAW_ONLY (0x00001000)Indicates that only raw data type print jobs can be spooled.

 

Syntax

attributes = printerControl.attributes

Settings

This is a read only property.

Applies To

printerControl

bottomMarginbasic


Description

Specifies the bottom margin height for HTML print-outs. Cannot be set to be less than the printer's physically unprintable area (unprintableBottom), in which case it will be automatically corrected to the minimum allowed value. If top and bottom margins are set to overlap, they will be corrected to an arbitrary default value of 1/10 of page height.

ScriptX uses the default units of measure of the user's system. In a broad network environment default units are certain to vary (they could be either inches or millimeters) so you may wish to specify a fixed unit of measure with the licensed function SetMarginMeasure.

The bottomMargin property is part of the basic freely-distributable printing subset.

Syntax

printing.bottomMargin = numMargin

Settings

This is a read/write property.

Applies To

printing

Example

Check out the source code of the ScriptX Advanced Printing and ScriptX Techie Printing examples.

See Also

HTML Printing with ScriptX

leftMarginpageHeightpageWidthportraitrightMargintopMarginunprintableBottomunprintableLeftunprintableRightunprintableTop

GetMarginMeasurePageSetupPrintPrintHTMLSetMarginMeasure

collate


Description

Specifies whether or not to collate the pages of HTML print-outs when more than one copy is printed.

Syntax

printing.collate = true|false

Settings

This is a read/write property. Use true to collate.

Applies To

printing

Example

Check out the source code of the ScriptX Techie Printing example.

See Also

HTML Printing with ScriptX

duplexprinter

PrintPrintHTMLPrintSetup

copies


Description

Specifies the number of copies for HTML print-outs.

Syntax

printing.copies = numCopies

Settings

This is a read/write property.

Applies To

printing

Example

Check out the source code of the ScriptX Techie Printing example.

See Also

HTML Printing with ScriptX

collateduplexprinter

PrintPrintHTMLPrintSetup

currentPrinter


Description

Specifies the printer to print to. Only the exact printer name strings as they appear on Internet Explorer's Print dialog can be specified. If the string does not exist or is written incorrectly, printing will be directed to the default printer.

Syntax

printing.currentPrinter = sPrinterName

Settings

This a read/write property. With JScript, take care to double a backslash if one appears in the printer name, as in the example below.

Usage

The internal implementation of writing to the currentPrinter property is the same as writing to the printer property, other than the implementation ofcurrentPrinter does not 'eat' any error. Therefore an error in currentPrinter will be reported in the same way as any other error that occurs in an ActiveX object property/method call.

Example

factory.printing.currentPrinter = "\\\\FS-LYS-01\\HP5n-759" // print to \\FS-LYS-01\HP5n-759

Applies To

printing

See Also

HTML Printing with ScriptX

printerEnumJobsEnumPrintersGetJobsCountIsTemplateSupportedPrint

 

disableUI


Description

Set to true to disable all of Internet Explorer's printing facilities, including the File/Page Setup, File/Print main menu commands, the Print context menu command and the window.print() scripting method. Given this, the only way left to print is via the ScriptX Print and PrintHTML methods.

Syntax

printing.disableUI = true|false

Settings

This is a read/write property.

Applies To

printing

Example

Check out the source code of the ScriptX Advanced Printing example.

See Also

HTML Printing with ScriptX

onpagesetuponuserpagesetuponuserprintonuserprintpreview

PageSetupPreviewPrintPrintSetup

duplex


Description

Duplex mode (if supported by the targeted printer).

Syntax

printing.duplex = number

Settings

This is a read/write property. Use for simplex mode (no duplex), for vertical duplex, for horizontal duplex.

Applies To

printing

See Also

HTML Printing with ScriptX

collatecopies

PrintPrintHTMLPrintSetup,

footerbasic


Description

Specifies the string to be used as the footer for HTML print-outs. String can include Internet Explorer header/footer metasymbols. If you need to use HTML for your headers and footers, check MaxiPT 1.0횂쨩 (Internet Explorer 5.5 or later).

The footer property is part of the basic freely-distributable printing subset.

Syntax

printing.footer = sFooter

Settings

This is a read/write property.

Applies To

printing

Example

Check out the source code of the ScriptX Advanced Printing and ScriptX Techie Printing examples.

See Also

HTML Printing with ScriptX

header

headerFooterFont

PageSetupPrintPrintHTML

headerbasic


Description

Specifies the string to be used as the header for HTML print-outs. String can include Internet Explrore header/footer metasymbols. If you need to use HTML for your headers and footers, check MaxiPT 1.0횂쨩 (Internet Explorer 5.5 or later).

The header property is part of the basic freely-distributable printing subset.

To print specific information as part of the header or footer, include the following characters as part of the string:

ShorthandMeaning
&wWindow title
&uPage address (URL)
&dDate in short format (as specified by Regional Settings in Control Panel)
&DDate in long format (as specified by Regional Settings in Control Panel)
&tTime in the format specified by Regional Settings in Control Panel
&TTime in 24-hour format
&pCurrent page number
&PTotal number of pages
&&A single ampersand (&)
&bThe text immediately following these characters as centered.
&b&bThe text immediately following the first "&b" as centered, and the text following the second "&b" as right-justified.

Syntax

printing.header = sHead

Settings

This is a read/write property.

Applies To

printing

Example

Check out the source code of the ScriptX Advanced Printing and ScriptX Techie Printing examples.

See Also

HTML Printing with ScriptX

footer

headerFooterFont

PageSetupPrintPrintHTML

headerFooterFontbasic


Description

From version 6.5.439, ScriptX supports retrieving and specifying the font used to render the document header and footer. The use of this feature requires Internet Explorer 8 or later.

Specifies or retrieves the description of the font to use. The font is described using a css style definition, one or more of the following semicolon-delimited values:

ValueDescription
font-familyThe font family name to use.
font-sizeThe size to use, units should be pixels.
colorThe colour for rendering the text, given as an RGB value - for example, rgb(255,0,0)
font-weightThe weight of the font as normal or bold
font-styleThe font style, as italicnormal, or oblique

Note: No error is thrown if this property is used with versions of Internet Explorer prior to 8 - settings are simply ignored.

Syntax

printing.headerFooterFont sFontSpec

Settings

This a read-write property.

Applies To

printing

Example

factory.printing.headerFooterFont = "font-family: Comic Sans MS; font-size: 10px; color: rgb(0,128,0); font-weight: bold;"

See Also

headerfooter

isLocal


Description

Returns whether the printer is a local printer (true) or not (false). isLocal tests whether PRINTER_ATTRIBUTE_LOCAL is set in the attributes.

Syntax

bIs = printerControl.isLocal

Settings

This is a read only property.

Applies To

printerControl

isNetwork


Description

Returns whether the printer is a network printer (true) or not (false). isNetwork tests whether PRINTER_ATTRIBUTE_NETWORK is set in the attributes.

Syntax

bIs = printerControl.isNetwork

Settings

This is a read only property.

Applies To

printerControl

isShared


Description

Returns whether the printer is a shared printer (true) or not (false). isShared tests whether PRINTER_ATTRIBUTE_SHARED is set in the attributes.

Syntax

bIs = printerControl.isShared

Settings

This is a read only property.

Applies To

printerControl

leftMarginbasic


Description

Specifies the left margin for HTML print-outs. Cannot be set to be less than the printer's physically unprintable area (unprintableLeft), in which case it will be automatically corrected to the minimum allowed value. If left and right margins overlap, they will be corrected to an arbitrary default value of 1/10 of page width.

ScriptX uses the default units of measure of the user's system. In a broad network environment default units are certain to vary (they could be either inches or millimeters) so you may wish to specify a fixed unit of measure with the licensed function SetMarginMeasure.

The leftMargin property is part of the basic freely-distributable printing subset.

Syntax

printing.leftMargin numMargin

Settings

This is a read/write property.

Applies To

printing

Example

Check out the source code of the ScriptX Advanced Printing and ScriptX Techie Printing examples.

See Also

HTML Printing with ScriptX

pageHeightpageWidthportraitrightMargintopMarginunprintableBottomunprintableLeftunprintableRightunprintableTop

GetMarginMeasurePageSetupPrintPrintHTMLSetMarginMeasure

location


Description

Returns a string describing the physical location of the printer.

Syntax

sLoc = printerControl.location

Settings

This is a read only property.

Applies To

printerControl

name


Description

Returns a string giving the name of the printer.

Syntax

sName = printerControl.name

Settings

This is a read only property.

Applies To

printerControl

onafterprint


Description

Event handler to be called when print spooling is done. The event is applicable to the results of a Print call but not to that of a PrintHTML call. It can be used to update the user interface accordingly. It is similar to the WaitForSpoolingComplete blocking call, but is asynchronous.

Note the difference between ScriptX's onafterprint event and the DHTML window.onafterprint event: the latter occurs after Internet Explorer has just made a document snapshot for printing and not after the actual print spooling job (see PRB: onafterprint Event Fires Before the Print Dialog Box Appears). So these two events are not interchangeable.

In fact, the DHTML window.onbeforeprint and window.onafterprint exist to give the document's script a chance to customize DHTML content before it goes to print-out or preview (and not to signal actual printing). The same effect can be achieved with the CSS  media=print or media=screen specific styles. Check out the following InsideDHTML.com articles: Printing TechniquesUsing CSS to specify alternate document to print out.

Syntax

printing.onafterprint = function_object

Settings

This is a read/write property.

Applies To

printing

Example

<script defer>
factory.printing.onafterprint = AfterPrint;

function AfterPrint() {
  alert("The document has been sent to the print spooler!");
}
</script>

See Also

HTML Printing with ScriptX

onpagesetuponuserpagesetuponuserprintonuserprintpreview

PrintWaitForSpoolingComplete

onbeforeunload


Description

String to prompt a user with when spooling (or a download originated by a PrintHTML call) is still in progress but the page is being closed or navigated away. By default, ScriptX waits 5 seconds in blocking mode to let spooling complete, then prompts the user with the choice to cancel the printing process. The user may decide to wait for another 5 seconds, and so on.

Note: to suppress the prompt you can force the blocking wait state with WaitForSpoolingComplete after any Print or PrintHTML call or before leaving the page. However the use of WaitForSpoolingComplete() after each PrintHTML call in a sequence of calls is not recommended. Use it only after the last call in the sequence.

Syntax

printing.onbeforeunload = string

Settings

This is a read/write property.

Applies To

printing

See Also

HTML Printing with ScriptX

PrintPrintHTMLWaitForSpoolingComplete

onpagesetup


Description

Event handler to be called when the current print or page setup settings are changed on the Internet Explorer Page Setup dialog. 

Use it to update the page's user interface accordingly. This is exactly what the ScriptX Techie Printing example does.

Syntax

printing.onpagesetup = function_object

Settings

This is a read/write property.

Applies To

printing

Example

Check out the source code of the ScriptX Techie Printing example.

See Also

HTML Printing with ScriptX

disableUIonafterprintonuserpagesetuponuserprintonuserprintpreview

PageSetup

onuserpagesetup


Description

Event handler to be called when a user invokes the Page Setup... command from Internet Explorer's File menu. 

You may cancel this operation within the event handler simply by returning, or you may call PageSetup to provide the expected behavior. In the latter case, once the user has made changes on the Page Setup dialog an onpagesetup event will be fired to update the page's user interface. ScriptX Techie Printing implements this behavior.

Syntax

printing.onuserpagesetup = function_object

Settings

This is a read/write property.

Applies To

printing

Example

Check out the source code of the ScriptX Techie Printing example.

See Also

HTML Printing with ScriptX

disableUIonafterprintonpagesetuponuserprintonuserprintpreview

PageSetup

onuserprint


Description

Event handler to be called when a user invokes the Print... command from the Internet Explorer File menu, or presses Print on the document's right-click context menu, or hits the printer button on the toolbar, or presses the Ctrl-P key combination, or when a script calls window.print().

You may cancel this operation within the event handler simply by returning, or you may call Print to provide the expected behavior. ScriptX Techie Printing implements this behavior.

Syntax

printing.onuserprint = function_object

Settings

This is a read/write property.

Applies To

printing

Example

Check out the source code of the ScriptX Techie Printing example.

See Also

HTML Printing with ScriptX

disableUIonafterprintonpagesetuponuserpagesetuponuserprintpreview

PageSetup

onuserprintpreview


Description

Event handler to be called when a user invokes the Preview... command from the Internet Explorer File menu or hits the print preview button on the toolbar.

You may cancel this operation within the event handler simply by returning, or you may call Preview to provide the expected behavior. ScriptX Techie Printing implements this behavior.

Syntax

printing.onuserprintpreview = function_object

Settings

This is a read/write property.

Applies To

printing

Example

Check out the source code of the ScriptX Techie Printing example.

See Also

HTML Printing with ScriptX

disableUIonafterprintonpagesetuponuserpagesetuponuserprint

PageSetup

pageHeight


Description

Returns the physical height of the current printer paper selection.

ScriptX uses the default units of measure of the user's system. In a broad network environment default units are certain to vary (they could be either inches or millimeters) so you may wish to specify a fixed unit of measure with the licensed function SetMarginMeasure.

Syntax

height = printing.pageHeight

Settings

This is a read-only property.

Applies To

printing

Example

Check out the source code of the ScriptX Techie Printing example.

See Also

HTML Printing with ScriptX

bottomMarginleftMarginpageWidthpaperSizeportraitrightMargintopMarginunprintableBottomunprintableLeftunprintableRightunprintableTop

PageSetupSetMarginMeasure

pageWidth


Description

Returns the physical width of the current printer paper selection.

ScriptX uses the default units of measure of the user's system. In a broad network environment default units are certain to vary (they could be either inches or millimeters) so you may wish to specify a fixed unit of measure with the licensed function SetMarginMeasure.

Syntax

width = printing.pageWidth

Settings

This is a read-only property.

Applies To

printing

Example

Check out the source code of the ScriptX Techie Printing example.

See Also

HTML Printing with ScriptX

bottomMarginleftMarginpageHeightpaperSizeportraitrightMargintopMarginunprintableBottomunprintableLeftunprintableRight,unprintableTop

PageSetupSetMarginMeasure

paperSize


Description

Specifies the paper size for HTML print-outs by its string name. ScriptX tries to find the longest string match amongst the list of available paper size names for the current printer. Read back the paperSize value to see the actual result.

Syntax

printing.paperSize = sPaperSize

Settings

This is a read/write property.

Applies To

printing

Example

Check out the source code of the ScriptX Techie Printing example.

See Also

HTML Printing with ScriptX

FormspageHeightpageWidthpaperSourceportraitunprintableBottomunprintableLeftunprintableRightunprintableTop

PageSetupPrintPrintHTMLPrintSetup,

paperSource


Description

Specifies the paper source (tray) for HTML print-outs by its string name. ScriptX tries to find the longest string match amongst the list of available paper source names for the current printer. Read back the paperSource value to see the actual result.

Syntax

printing.paperSource = sPaperSource

Settings

This is a read/write property.

Applies To

printing

Example

Check out the source code of the ScriptX Techie Printing example.

See Also

HTML Printing with ScriptX

BinspaperSize

PageSetupPrintPrintHTMLPrintSetup

port


Description

Returns a string string that identifies the port(s) used to transmit data to the printer. If a printer is connected to more than one port, the names of each port will be separated by commas (for example, "LPT1:,LPT2:,LPT3:").

Windows 95/98/Me: This member can specify only one port because multiple ports per printer are not supported.

Syntax

sName = printerControl.port

Settings

This is a read only property.

Applies To

printerControl

portraitbasic


Description

Specifies the page orientation for HTML print-outs.

The portrait property is part of the basic freely-distributable printing subset.

Syntax

printing.portrait = true|false

Settings

This is a read/write property. Use true to specify portrait and false for landscape.

Applies To

printing

Example

Check out the source code of the ScriptX Techie Printing example.

See Also

HTML Printing with ScriptX

bottomMarginleftMarginpageHeightpageWidthpaperSizetemplateURLtopMarginunprintableBottomunprintableLeftunprintableRight,unprintableTop

PageSetupPrintPrintHTMLPrintSetup

printBackground


Description

Specifies whether or not to print a page's background colors and images.

Syntax

printing.printBackground = true|false

Settings

This is a write-only property.

Applies To

printing

Example

Check out the source code of the ScriptX Techie Printing example.

See Also

HTML Printing with ScriptX

PreviewPrintPrintHTML

printer


Description

Specifies the printer to print to. Only the exact printer name strings as they appear on Internet Explorer's Print dialog can be specified. If the printer specified does not exist or is written incorrectly, printing will be directed to the default printer.

Syntax

printing.printer = sPrinterName

Settings

This a write-only property. With JScript, take care to double a backslash if one appears in the printer name, as in the example below.

Please note that providing an invalid name will not raise an error - the request will be ignored and the printer to use remain unchanged. To trap errors specifying the printer to use, use the currentPrinter property.

Applies To

printing

Example

factory.printing.printer = "\\\\FS-LYS-01\\HP5n-759" // print to \\FS-LYS-01\HP5n-759

Also check out the source code of the ScriptX Techie Printing example.

SSee Also

HTML Printing with ScriptX

rawPrinting

bottomMargin,collatecopiescurrentPrinterduplexfooterheaderleftMarginpaperSizepaperSourceportraitprintBackgroundprintToFileName,rightMargintemplateURLtopMargin

DefaultPrinterEnumJobsEnumPrintersGetJobsCountIsSpoolingIsTemplateSupportedPrintHTMLPrintSetupSetPageRange,WaitForSpoolingComplete

printer  (v6.3.436 and later)


Description

Specifies the printer to directly print to. Only the exact printer name strings as they appear in the Printers Control Panel may be used.

Syntax

rawPrinting.printer = sPrinterName

Settings

This a read-write property. With JScript, take care to double a backslash if one appears in the printer name.

Please note that an error will be thrown if the printer cannot be connected to.

Applies To

rawPrinting

Example

factory.rawPrinting.printer = "Zebra  LP2844-Z"

See Also

printStringprintDocument

 

printToFileName


Description

The file name to print to. Use the full path specification. The file created doesn't accumulate subsequent print-outs and - for security reasons - doesn't get overwritten if it already exists. Specify a new filename for each new print-out.

Printing to file name is supported for Internet Explorer 5.0 and later.

Syntax

printing.printToFileName = sPathFileName

Settings

This is a read/write property. With JScript, take care to double a backslash if one appears in the file path, as in the example below. An empty string indicates that the print-out should go to the printer driver.

Applies To

printing

Example

factory.printing.printToFileName = "d:\\temp\\printout.prn"

See Also

HTML Printing with ScriptX

printer

IsSpoolingPrintPrintHTMLPrintSetupWaitForSpoolingComplete

rightMarginbasic


Description

Specifies the right margin for HTML print-outs. Cannot be set to be less than the printer's physically unprintable area (unprintableRight), in which case it will be automatically corrected to the minimum allowed value. If left and right margins overlap, they will be corrected to an arbitrary default value of 1/10 of page width.

ScriptX uses the default units of measure of the user's system. In a broad network environment default units are certain to vary (they could be either inches or millimeters) so you may wish to specify a fixed unit of measure with the licensed function SetMarginMeasure.

The rightMargin property is part of the basic freely-distributable printing subset.

Syntax

printing.rightMargin numMargin

Settings

This is a read/write property.

Applies To

printing

Example

Check out the source code of the ScriptX Advanced Printing and ScriptX Techie Printing examples.

See Also

HTML Printing with ScriptX

pageHeightpageWidthportraitleftMargintopMarginunprintableBottomunprintableLeftunprintableRightunprintableTop

GetMarginMeasurePageSetupPrintPrintHTMLSetMarginMeasure

serverName


Description

Returns a string giving the name of the server computer controlling the printer. If the string is empty then the printer is controlled locally.

Syntax

sName = printerControl.serverName

Settings

This is a read only property.

Applies To

printerControl

shareName


Description

Returns a string identifying the share point of the printer. This value is only present if PRINTER_ATTRIBUTE_SHARED is set on attributes.

Syntax

sName = printerControl.shareName

Settings

This is a read only property.

Applies To

printerControl

status


Description

Specifies the status of the printer, it can be any reasonable combination of the following values.

ValueMeaning
PRINTER_STATUS_BUSY (0x00000200)The printer is busy.
PRINTER_STATUS_DOOR_OPEN (0x00400000)The printer door is open.
PRINTER_STATUS_ERROR (0x00000002)The printer is in an error state.
PRINTER_STATUS_INITIALIZING (0x00008000)The printer is initializing.
PRINTER_STATUS_IO_ACTIVE (0x00000100)The printer is in an active input/output state
PRINTER_STATUS_MANUAL_FEED (0x00000020)The printer is in a manual feed state.
PRINTER_STATUS_NO_TONER (0x00040000)The printer is out of toner.
PRINTER_STATUS_NOT_AVAILABLE (0x00001000)The printer is not available for printing.
PRINTER_STATUS_OFFLINE (0x00000080)The printer is offline.
PRINTER_STATUS_OUT_OF_MEMORY (0x00200000)The printer has run out of memory.
PRINTER_STATUS_OUTPUT_BIN_FULL (0x00000800)The printer's output bin is full.
PRINTER_STATUS_PAGE_PUNT (0x00080000)The printer cannot print the current page.

Windows 95/98/Me: Indicates the page is being "punted" (that is, not printed) because it is too complex for the printer to print.

PRINTER_STATUS_PAPER_JAM (0x00000008)Paper is jammed in the printer
PRINTER_STATUS_PAPER_OUT (0x00000010)The printer is out of paper.
PRINTER_STATUS_PAPER_PROBLEM 0x00000040)The printer has a paper problem.
PRINTER_STATUS_PAUSED (0x00000001)The printer is paused.
PRINTER_STATUS_PENDING_DELETION (0x00000004)The printer is being deleted.
PRINTER_STATUS_POWER_SAVE (0x01000000)The printer is in power save mode.
PRINTER_STATUS_PRINTING (0x00000400)The printer is printing.
PRINTER_STATUS_PROCESSING (0x00004000)The printer is processing a print job.
PRINTER_STATUS_SERVER_UNKNOWN (0x00800000)The printer status is unknown.
PRINTER_STATUS_TONER_LOW (0x00020000)The printer is low on toner.
PRINTER_STATUS_USER_INTERVENTION (0x00100000)The printer has an error that requires the user to do something.
PRINTER_STATUS_WAITING (0x00002000)The printer is waiting.
PRINTER_STATUS_WARMING_UP (0x00010000)The printer is warming up.

Syntax

printerControl.status = nStatus

Settings

This is a read/write property. The user will require printer administrator writes in order to update the status.

Applies To

printerControl

templateURLbasic (v6.3 and later)


Description

 

For ScriptX v6.3 and later, this property is available as basic  property, the value set must be one of the following special values:

ValueDescription
MeadCo://IE55The IE 5.5/IE 6 style template - note can be used on IE 7.
MeadCo://IE7The IE 7 style template - note free usage on all versions of IE 5.5 or later.
MeadCo://DefaultThe default template for the IE version in use, i.e. the template matches the browser version. This is the default behaviour.
MeadCo://maxiptThe MaxiPT template (requires a license).

Syntax

printing.templateURL templateURL

Settings

This is a read/write property.

Applies To

printing

See Also

 PrintPrintHTML

topMarginbasic


Description

Specifies the top  margin for HTML print-outs. Cannot be set to be less than the printer's physically unprintable area (unprintableTop), in which case it will be automatically corrected to the minimum allowed value. If top and bottom margins overlap, they will be corrected to default value of 1/10 of page width.

ScriptX uses the default units of measure of the user's system. In a broad network environment default units are certain to vary (they could be either inches or millimeters) so you may wish to specify a fixed unit of measure with the licensed function SetMarginMeasure.

The topMargin property is part of the basic freely-distributable printing subset.

Syntax

printing.topMargin = numMargin

Settings

This is a read/write property.

Applies To

printing

Example

Check out the source code of the ScriptX Advanced Printing and ScriptX Techie Printing examples.

See Also

HTML Printing with ScriptX

leftMarginpageHeightpageWidthportraitrightMarginbottomMarginunprintableBottomunprintableLeftunprintableRightunprintableTop

GetMarginMeasurePageSetupPrintPrintHTMLSetMarginMeasure

unprintableBottom


Description

Returns the bottom unprintable page area (in current system measure units, inches or millimeters) for the current printer. It indicates the distance from the bottom edge of the page where no printing may occur.

Syntax

numMargin = printing.unprintableBottom

Settings

This is a read/only property.

Applies To

printing

See Also

HTML Printing with ScriptX

bottomMarginleftMarginpageHeightpageWidthpaperSizetopMarginunprintableLeftunprintableRightunprintableTop

PageSetupPrintPrintSetup

unprintableLeft


Description

Returns the left unprintable page area (in current system measure units, inches or millimeters) for the current printer. It indicates the distance from the left edge of the page where no printing may occur.

Syntax

numMargin = printing.unprintableLeft

Settings

This is a read/only property.

Applies To

printing

See Also

HTML Printing with ScriptX

bottomMarginleftMarginpageHeightpageWidthpaperSizetopMarginunprintableBottomunprintableRightunprintableTop

PageSetupPrintPrintSetup

unprintableRight


Description

Returns the right unprintable page area (in current system measure units, inches or millimeters) for the current printer. It indicates the distance from the right edge of the page where no printing may occur.

Syntax

numMargin = printing.unprintableRight

Settings

This is a read/only property.

Applies To

printing

See Also

HTML Printing with ScriptX

bottomMarginleftMarginpageHeightpageWidthpaperSizetopMarginunprintableBottomunprintableLeftunprintableTop

PageSetupPrintPrintSetup

unprintableTop


Description

Returns the top unprintable page area (in current system measure units, inches or millimeters) for the current printer. It indicates the distance from the top edge of the page where no printing may occur.

Syntax

numMargin = printing.unprintableTop

Settings

This is a read/only property.

Applies To

printing

See Also

HTML Printing with ScriptX

bottomMarginleftMarginpageHeightpageWidthpaperSizetopMarginunprintableBottomunprintableLeftunprintableRight

PageSetupPrintPrintSetup



Methods and Functions

BatchPrintPDF (ScriptX Corporate 32 bit Edition)


Description

Downloads Adobe Acrobattm or Microsoft Officetm files and prints them out in batch mode in the background. Any number of print-outs can be queued.

For Microsoft Officetm files, BatchPrintPDF prints only on the default printer using default settings.

For Adobe Acrobattm files, relevant current printing settings are used as described in the syntax section.

This updated functionality now requires v6.6 or later of ScriptX Corporate 32-bit Edition and an Enhanced PDF Printing license.

Please contact MeadCo sales for details.

Use IsSpooling to check if there are any outstanding downloads in the queue created by BatchPrintPDF. Use WaitForSpoolingComplete to wait for all documents to be downloaded and spooled.

Syntax

printing.BatchPrintPDF(url)

ParameterDescription
urlThe url of the document to be printed.

For Adobe Acrobattm files, the following printing settings are used:

printing.printer
printing.paperSize
printing.paperSource
printing.portrait
printing.copies
printing.collate
printing.duplex
printing.SetPrintScale(-1). 
    [The use of SetPrintScale(-1) enables "Shrink to Fit" of the printed output. Also, rotate pages to fit on the output medium, and center on the page is set. Any other value given to SetPrintScale is ignored.] printing.SetPageRange(false,startPage,endPage) to set the page range to print.

These settings are used per file submitted to the batch, so each document can be printed using different settings, for example, each document to a different printer.

Example

Here is a basic example of BatchPrintPDF use

<body>
<script>
function BatchPrintPDF(url) {
  factory.printing.SetPrintScale(-1); // ensure shrinks to fit if needed
  factory.printing.BatchPrintPDF(url);
}
</script>
<button id="idPrint" onclick="BatchPrintPDF('report.pdf')">BatchPrintPDF('report.pdf')</button>
</body>

Applies To

printing

See Also

HTML Printing with ScriptX

DefaultPrinterEnumJobsEnumPrintersGetJobsCountIsSpoolingPrintHTMLPrintPDFSleepWaitForSpoolingComplete

DefaultPrinter


Description

Returns the name of the default printer (if any).

Syntax

printerName = printing.DefaultPrinter()

Applies To

printing

See Also

HTML Printing with ScriptX

printer

EnumJobsEnumPrintersGetJobsCountIsTemplateSupportedPrint

DoPrint


Description

The alias for the Print method (retained for compatibility reasons).

Applies To

factory

See Also

printingPrintPrintHTML

EnumJobs


Description

Enumerates active jobs on the given printer.

Syntax

var jobName = {}
status = printing
.EnumJobs(printerName, index, jobName)

ParameterDescription
printerName(String) printer name on which to enumerate the jobs
index(Number) Zero-based index of the job. Increment this value for each new EnumJobs call for a given printerName
An index of -1 will return the status of the printer, rather than a particular job.
jobName(Object) obtains a name for the job (available as jobName[0])

Return Value

Returns a numeric value indicating the current status of the job. The bits have the following meaning:

MeaningValue
JOB_STATUS_PAUSED0x00000001
JOB_STATUS_ERROR0x00000002
JOB_STATUS_DELETING0x00000004
JOB_STATUS_SPOOLING0x00000008
JOB_STATUS_PRINTING0x00000010
JOB_STATUS_OFFLINE0x00000020
JOB_STATUS_PAPEROUT0x00000040
JOB_STATUS_PRINTED0x00000080
JOB_STATUS_DELETED0x00000100
JOB_STATUS_BLOCKED_DEVQ0x00000200
JOB_STATUS_USER_INTERVENTION0x00000400
JOB_STATUS_RESTART0x00000800

Example

<script defer>
function window.onload() {
  for ( i = 0; printer = factory.printing.EnumPrinters(i); i++ ) {
    alert("Printer name: "+printer);
    var job = {};
    for ( j = 0; status = factory.printing.EnumJobs(printer, j, job); j++ )
      alert("Job name: "+job[0]+", status: "+status);
  }
}
</script>

Applies To

printing

See Also

HTML Printing with ScriptX

printer

DefaultPrinterEnumPrintersGetJobsCountPrint

EnumPrinters


Description

Enumerates locally-available printers.

Syntax

printerName = printing.EnumPrinters(index)

ParameterDescription
index(Number) Zero-based index of the printer. Increment this value for each new EnumPrinters call

Return Value

Returns the string name of the next printer. An empty value means that enumeration is over.

Example

<!-- MeadCo Security Manager - using evaluation license -->
<object viewastext style="display:none"
classid="clsid:5445be81-b796-11d2-b931-002018654e2e"
codebase="smsx.cab#Version=7,0,0,8">
  <param name="GUID" value="{0ADB2135-6917-470B-B615-330DB4AE3701}">
  <param name="Path" value="sxlic.mlf">
  <param name="Revision" value="0">
</object>

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

<p><small id=idOutput></small>

<script defer>
function OutputHtml(html) {
  idOutput.insertAdjacentHTML("BeforeEnd", html)
  idOutput.scrollIntoView(false)
}

function EnumAll() {
  OutputHtml("Default printer: <b>" + factory.printing.DefaultPrinter() + "</b><br>")
  for ( i = 0; name = factory.printing.EnumPrinters(i); i++ ) {
    OutputHtml("Printer: <b>" + name + "</b><br>Job count: " + factory.printing.GetJobsCount(name) + "<br>")
    var jobName = {}
    for ( j = 0; status = factory.printing.EnumJobs(name, j, jobName); j++ )
      OutputHtml("Job: <b>" + jobName[0]+"</b>Status: " + new Number(status).toString(16) + "<br>")
  }
}

function window.onload() {
  EnumAll()
}
</script>

Applies To

printing

See Also

HTML Printing with ScriptX

printer

DefaultPrinterEnumJobsEnumPrintersGetJobsCountPrintPrintSetup

GetJobsCount


Description

Returns the number of printing jobs for the specified printer.

Syntax

numJobs = printing.GetJobsCount(printer)

Return Value

Returns a numeric value.

Applies To

printing

See Also

HTML Printing with ScriptX

printer

DefaultPrinterEnumJobsEnumPrintersPrint

GetMarginMeasure


Description

Returns current units of measure for print-out margins, either millimeters or inches. Use SetMarginMeasure to switch the default units.

Syntax

units = printing.GetMarginMeasure()

Return Value

Returns the currently-set units of measure. 1 stands for millimeters, 2 for inches.

Applies To

printing

Example

Check out the source code of the ScriptX Advanced Printing and ScriptX Techie Printing examples.

See Also

HTML Printing with ScriptX

bottomMarginleftMarginpageHeightpageWidthrightMargintemplateURLtopMarginunprintableBottomunprintableLeftunprintableRight,unprintableTop

PageSetupPrintPrintPrintSetupSetMarginMeasure

IsSpooling


Description

Checks if spooling is in progress as result of a Print call, or for any downloads outstanding in the queue created by PrintHTML PrintXML orBatchPrintPDF calls.

You can force the blocking wait state with WaitForSpoolingComplete to make sure all downloads are complete and spooling is done at any point in your code.

Syntax

isSpooling = printing.IsSpooling()

Return Value

Returns a boolean value indicating whether or not there are still outstanding unspooled downloads to be printed

Example

The following example closes the window when the spooling is done:

<script defer>

function PrintAllDocs() {
  factory.printing.PrintHTML("info.htm");
  factory.printing.PrintXML(src1);
  factory.printing.PrintXML(src2);
  CheckSpooling();
}

function CheckSpooling() {
  if ( !factory.printing.IsSpooling() ) window.close()
  setTimeout("CheckSpooling()", 1000);
}

</script>

See Also

HTML Printing with ScriptX

onafterprintonbeforeunload

BatchPrintPDFOwnQueuePrintPrintHTMLPrintXMLSleepWaitForSpoolingComplete

IsTemplateSupportedbasic


Description

Checks whether or not Print Templates are supported on the end user's system (i.e. checks for Internet Explorer 5.5 or later).

Syntax

isTemplateSupported = printing.IsTemplateSupported()

Return Value

Returns a boolean value indicating whether or not Print Templates are supported.

Applies To

printing

See Also

HTML Printing with ScriptX

templateURL

PreviewPrintPrintHTML

OwnQueue


Description

OwnQueue is used to organize a detached printing queue. Use this method to queue all PrintHTML calls in a separate process. The process is disconnected from the current session (cookies, SSL context, etc) but the calling window can be closed at any time without waiting for spooling to compete. 

OwnQueue should be called before any PrintHTML or PrintXML commands to take effect.

Syntax

printing.OwnQueue()

Applies To

printing

See Also

PrintHTMLPrintXML

PageSetupbasic


Description

Invokes the standard Internet Explorer Page Setup... dialog. If the user closes the dialog with the OK button, current settings will be updated and anonpagesetup event will be fired. 

The PageSetup method is part of the basic freely-distributable printing subset.

Syntax

result = printing.PageSetup()

Return Value

Returns a boolean value indicating whether or not a user has closed the dialog with the OK button.

Example

Check out the source code of the ScriptX Advanced Printing and ScriptX Techie Printing examples.

Applies To

printing

See Also

HTML Printing with ScriptX

bottomMargindisableUIfooterheaderleftMarginonpagesetuponuserpagesetuppaperSizepaperSourceportraitrightMargintopMargin

PrintPrintHTMLPrintSetup

Pause


Description

Pauses either the entire print queue or an individual job. In order to pause a print queue the user must possess administration rights on the printer, jobs belonging to the user may be paused.

Syntax

o.Pause()

Applies To

printerControlJob

See Also

Resume

Previewbasic


Description

Invokes the Print Preview... pane in Internet Explorer 5.5 and later.

The Preview method is part of the basic freely-distributable printing subset.

Syntax

printing.Preview(oFrame)

ParameterDescription
oFrame[Optional] HTML frame to preview. By default, the top-level containing page will be previewed (i.e. the whole browser window content).

The use of this parameter is not part of the basic subset, a license is required. Without a license, default behaviour (preview the whole window) will occur.

Applies To

printing

Example

Check out the source code of the ScriptX Advanced Printing and ScriptX Techie Printing examples.

See Also

HTML Printing with ScriptX

onuserprintpreviewtemplateURL

IsTemplateSupportedPrint

Printbasic


Description

Prints the contents of the specified window or frame using the current printing settings. Please note these important changes regarding printing without a prompt.

This method is part of the basic freely-distributable printing subset.

However, the acquisition of a MeadCo Publishing License means that you can customize various printing properties such as copiesduplexpaperSize,printBackground etc., target specific printer or print externally-located documents with PrintHTML. See HTML Printing with ScriptX for more info. 

Syntax

printing.Print([prompt[, frameOrWindow]])

ParameterDescription
prompt(Bool) whether or not to prompt
frameOrWindow(Object) optional HTML frame or window횂쨩 to print. By default, the containing page (that hosts the ScriptX object) will be printed

Return Value

Returns false if printing with a prompt and the user cancels the printing.

Example

Check out the source code of the ScriptX BasicAdvanced and Techie printing examples.

The following simple but complete example shows how to print the containing page:

<head>
<title>MeadCo's ScriptX: Print</title>
<!-- special style sheet for printing -->
<style media="print">
.noprint { display: none }
</style>
</head>

<body scroll="auto">

<!-- MeadCo Security Manager - using evaluation license -->
<object viewastext style="display:none"
classid="clsid:5445be81-b796-11d2-b931-002018654e2e"
codebase="smsx.cab#Version=7,0,0,8">
  <param name="GUID" value="{0ADB2135-6917-470B-B615-330DB4AE3701}">
  <param name="Path" value="sxlic.mlf">
  <param name="Revision" value="0">
</object>

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

<script defer>
function window.onload() {
  factory.printing.header = "MeadCo's ScriptX: Print"
  factory.printing.footer = "The de facto standard for advanced web-based printing"
  factory.printing.portrait = false
  idPrint.disabled = false; // enable UI button
}

function Print() {
  factory.printing.Print(false); // no prompt
}
</script>

<p>Hello, world!</p>

<div class=noprint>
<hr>The button itself will not be printed:
<input id=idPrint disabled type="button" value="Print w/o prompt" onclick="Print()">
</div>

</body>

Applies To

printing

See Also

HTML Printing with ScriptX

bottomMargincollatecopiesduplexfooterheaderleftMarginonafterprintonuserprintpaperSizepaperSourceportraitprintBackgroundprinter,printToFileNamerightMargintemplateURLtopMargin

DefaultPrinterEnumJobsEnumPrintersGetJobsCountGetMarginMeasureIsSpoolingIsTemplateSupportedOwnQueuePageSetupPreviewPrint,PrintHTMLPrintPDFPrintSetupPrintXMLSetMarginMeasureSetPageRange,, WaitForSpoolingComplete

printDocument  (v6.3.436 and later)


Description

Loads the specified file and sends the content directly to the printer. The file bytes are not rendered in any way, they are sent to the printer for the printer to interpret. In this way, postscript can be sent directly to the printer or label printing commands.

This method is synchronous; it will not return until the file load and print is complete.

Syntax

rawPrinting.printDocument(url)

ParameterDescription
url(String) url of the file whose contents are to be sent to the printer. The url must be absolute but may refer to local (file://) resources.

Return Value

none.

Applies To

rawPrinting

Examples

The following simple but complete example shows how to print a label stored on the web server to a Zebra printer. The sample is assuming that some process has run on the server to generate and store the required label.

<head>

<!-- MeadCo Security Manager - using evaluation license -->
<object viewastext style="display:none"
classid="clsid:5445be81-b796-11d2-b931-002018654e2e"
codebase="smsx.cab#Version=7,0,0,8">
  <param name="GUID" value="{0ADB2135-6917-470B-B615-330DB4AE3701}">
  <param name="Path" value="sxlic.mlf">
  <param name="Revision" value="0">
</object>

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

<script defer>

function printLabel() {
  var p = factory.rawPrinting;

  // select the Zebra printer
  p.printer = "Zebra  LP2844-Z"

  // must give the full url of the file...
  // The printDocument method is synchronous
  p.printDocument(factory.baseURL("label.txt"));

}
</script>


</head>

See Also

printString

PrintHTML


Description

Prints either specified HTML text or the HTML or XML document specified by the URL using the current printing settings in the same session context. The method is asynchronous. It returns before the document is downloaded and printed.

Important note:

The html to be printed must not be 'ScriptX-enabled' - it must not contain an object tag referencing the ScriptX object nor script code that uses that object. Attempting to print html (either specified html text or document specified by url) that contains the ScriptX object can lead to strange errors and failure of the entire printing process, including causing Internet Explorer to stop responding.

PrintHTML may be used to organize a printing queue in a separate process, in which case the current window may be closed without waiting for pending downloads to complete. See OwnQueue for more details.

Syntax

printing.PrintHTML(url[, prompt = false])

ParameterDescription
url(String) URL/html text to print:
ProtocolPrints
html://The html is loaded and printed, e.g. html://<html><head><title>Dynamic Printing</title></head><body>Hello world!</body></html>
any other, e.g. http://, https:// or if no protocol specified.The document is downloaded and printed. A relative (to the current page) url may be given.

Note: The target document at 'url' must NOT be 'ScriptX-enabled'.
prompt(Bool) Specifies whether or not the user should be prompted before the download is queued

Return Value

Returns false if printing with a prompt and the user cancels the printing.

Applies To

printing

Examples

Check out the source code of the ScriptX Advanced Printing and ScriptX Techie Printing examples.

The following simple but complete example shows how to print an externally-located document:

<body>

<!-- MeadCo Security Manager - using evaluation license -->
<object viewastext style="display:none"
classid="clsid:5445be81-b796-11d2-b931-002018654e2e"
codebase="smsx.cab#Version=7,0,0,8">
  <param name="GUID" value="{0ADB2135-6917-470B-B615-330DB4AE3701}">
  <param name="Path" value="sxlic.mlf">
  <param name="Revision" value="0">
</object>

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

<script defer>
function window.onload() {
  idPrint.disabled = false;
}

function PrintHTML(url) {
  factory.printing.PrintHTML(url);
}
</script>

<input id=idPrint disabled type="button" value="PrintHTML('info.htm')"
 onclick="PrintHTML('info.htm')">

</body>

The following example illustrates dynamic creation of the HTML to be printed:

 <!-- MeadCo Security Manager - using evaluation license -->
<object viewastext style="display:none"
classid="clsid:5445be81-b796-11d2-b931-002018654e2e"
codebase="smsx.cab#Version=7,0,0,8">
  <param name="GUID" value="{0ADB2135-6917-470B-B615-330DB4AE3701}">
  <param name="Path" value="sxlic.mlf">
  <param name="Revision" value="0">
</object>

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

<script>
function doPrintDemo() {

	var n;
	var str = "<html><head>";
	str += "<link rel='stylesheet' type='text/css' href='/zeepe/resources/zp_content.css' />";
	str += "<title>ScriptX Dynamic Reports</title></head><body>";

	for (n=0; n<10; n++) {
		str += "<p>Dynamically created line number: " + (n+1) + "</p>";
	}

	str += "<hr/><p>Note that style sheets, scripts, images etc must be referenced by their full url</p>");
	str += "</body></html>";

	factory.printing.header = "ScriptX Dynamic Printing";
	factory.printing.footer = "";
	factory.printing.printHTML("html://"+str);
}
</script>

See Also

HTML Printing with ScriptX

bottomMargincollatecopiesduplexfooterheaderleftMarginonafterprintonuserprintpaperSizepaperSourceportraitprintBackgroundprinter,printToFileNamerightMargintemplateURLtopMargin

BatchPrintPDFIsSpoolingOwnQueuePageSetupPrintPrintSetupPrintXMLWaitForSpoolingComplete

PrintPDF (ScriptX Corporate 32 bit Edition)


Description

Downloads and prints a PDF document - the method will not return until the download and print has completed.

For greater control over printing, such as being able to select paper size and source and the printer to use and for a responsive experience for the user, please see the BatchPrintPDF method.

This updated functionality now requires v6.6 or later of ScriptX Corporate 32-bit Edition and an Enhanced PDF Printing license.

Please contact MeadCo sales for details.

Syntax

printing.PrintPDF(PDF[, prompt = true[, shrinkToFit = true [, from = -1[, to = -1]]]);

ParameterDescription
PDFAnonymous javascript object with the member value url containing the location of the document to be printed, as illustrated below.
prompt(Bool) Indicates whether or not to prompt the user before printing
shrinkToFit(Bool) Shrink the PDF page to fit the paper, optional, true by default
from(Number) Print from the specified page, optional, all pages by default
to(Number) Print to the specified page, optional, all pages by default

Example

<body>

<!-- MeadCo Security Manager - using evaluation license -->
<object viewastext style="display:none"
classid="clsid:5445be81-b796-11d2-b931-002018654e2e"
codebase="smsx.cab#Version=7,0,0,8">
  <param name="GUID" value="{0ADB2135-6917-470B-B615-330DB4AE3701}">
  <param name="Path" value="sxlic.mlf">
  <param name="Revision" value="0">
</object>

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

<script defer>
function PrintPDF() {
  factory.printing.PrintPDF({ url: "example.pdf" });
}
</script>

<input id=idPrint type="button" value="Print the PDF"
 onclick="PrintPDF()">

</body>

Applies To

printing

See Also

HTML Printing with ScriptX

BatchPrintPDFPrintPrintHTML

PrintSetup


Description

Invokes the standard Windows Print Setup... dialog, thus allowing a user to modify current print settings. If the user closes the dialog with the OK button, current settings will be updated and an onpagesetup event will be fired. No printing will occur in either case. 

Syntax

result = printing.PrintSetup()

Return Value

Returns a boolean value indicating whether or not the user has closed the dialog with the OK button.

Example

Check out the source code of the ScriptX Advanced Printing and ScriptX Techie Printing examples.

Applies To

printing

See Also

HTML Printing with ScriptX

collatecopiesdisableUIduplexprinterprintToFileName

DefaultPrinterPageSetupPrintPrintHTML

printString


Description

Sends the specified text directly to the printer. The string is not rendered in any way, its is sent to the printer for the printer to interpret. In this way, label printing commands or (say) postscript can be sent directly to the printer.

This method is synchronous; it will not return until the print is complete.

Syntax

rawPrinting.printString(sText)

ParameterDescription
sText(String) text to print. The string is converted from Unicode to an ANSI string (bytes) and sent as-is to the printer.

Return Value

none.

Applies To

rawPrinting

Examples

The following simple but complete example shows how to print a label to a Zebra printer:

<head>

<!-- MeadCo Security Manager - using evaluation license -->
<object viewastext style="display:none"
classid="clsid:5445be81-b796-11d2-b931-002018654e2e"
codebase="smsx.cab#Version=7,0,0,8">
  <param name="GUID" value="{0ADB2135-6917-470B-B615-330DB4AE3701}">
  <param name="Path" value="sxlic.mlf">
  <param name="Revision" value="0">
</object>

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

<script defer>

function printLabel() {
  var p = factory.rawPrinting;

  p.printer = "Zebra  LP2844-Z"
  p.printString("^XA^FO50,50^ADN,36,20,^FDScriptX RawPrinting^FS^FO50,100^ADN,36,20,^FDMead & Company^FS^XZ");

}
</script>


</head>

See Also

printDocument

PrintXML


Description

This method is an alias for PrintHTML, preserved for compatibility reasons. You can print both XML (XSL-processed) and HTML files with PrintHTML. See the PrintHTML method description for more info.

Example

The following simple but complete example shows how to print an externally-located XML document:

<head>
<title>MeadCo's ScriptX: PrintXML</title>
<!-- special style sheet for printing -->
<style media="print">
.noprint     { display: none }
</style>
</head>

<body>

<!-- MeadCo Security Manager - using evaluation license -->
<object viewastext style="display:none"
classid="clsid:5445be81-b796-11d2-b931-002018654e2e"
codebase="smsx.cab#Version=7,0,0,8">
  <param name="GUID" value="{0ADB2135-6917-470B-B615-330DB4AE3701}">
  <param name="Path" value="sxlic.mlf">
  <param name="Revision" value="0">
</object>

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

<script defer>
function window.onload() {
  idPrint.disabled = false;
}

function Print() {
  // set footer
  factory.printing.footer = "Printed with MeadCo's ScriptX";

  // print this page
  factory.printing.Print(false);

  // print linked pages
  var links = idLinks.all.tags("A");
  for ( i = 0; i < links.length; i++ )
    factory.printing.PrintXML(links[i].href)
}
</script>

<p><input id=idPrint class=noprint disabled type="button" value="Print the page and links"
 onclick="Print()">

<p>XML links:
<span id=idLinks>
<a href="info1.xml">Info 1</a>
<a href="info2.xml">Info 2</a>
<a href="info3.xml">Info 3</a>
</span>

</body>

See Also

HTML Printing with ScriptX

bottomMargincollatecopiesduplexfooterheaderleftMarginonafterprintonuserprintpaperSizepaperSourceportraitprintBackgroundprinter,printToFileNamerightMargintemplateURLtopMargin

BatchPrintPDFIsSpoolingOwnQueuePageSetupPrintPrintHTMLPrintSetupWaitForSpoolingComplete

Purge


Description

Purges all pending print jobs in the queue for the printer. The user must posses administration rights on the printer.

Syntax

o.Purge()

Applies To

printerControl

See Also

Pause

Restart


Description

Restarts the print job - the job must belong to the user or the user must possess administration rights on the printer.

Syntax

job.Restart()

Applies To

Job

See Also

Pause

Resume


Description

Resumes either the entire print queue or an individual job. In order to resume a paused print queue the user must possess administration rights on the printer, paused jobs belonging to the user may be resumed.

Syntax

o.Resume()

Applies To

printerControlJob

See Also

Pause

SetMarginMeasure


Description

Sets the units of measure for print-out margins.

Syntax

printing.SetMarginMeasure(units)

ParameterDescription
units(Number) 1 stands for millimeters, 2 for inches.

Applies To

printing

Example

Check out the source code of the ScriptX Advanced Printing and ScriptX Techie Printing examples.

See Also

HTML Printing with ScriptX

bottomMarginleftMarginpageHeightpageWidthpaperSizerightMargintopMarginunprintableBottomunprintableLeftunprintableRight,unprintableTop

GetMarginMeasurePageSetupPrintPrintPrintSetup

SetPageRange


Description

Sets the page selection to print.

It is not possible to know in advance the exact number of pages which will be printed unless you're using a custom Print Template (Internet Explorer 5.5 or later). MeadCo's MaxiPT횂쨩 custom Print Template allows you to specify arbitrary page ranges, as well as only odd, even or both odd and even pages with different margin and header/footer settings. 

Syntax

printing.SetPageRange(selectionOnly[, fromto])

ParameterDescription
selectionOnlyif true, prints the highlighted selection only (if there is one) and from and to are ignored.
If there is no selection, all pages are printed.
fromThe (1-based) page number to start printing from - use 0 to signify all pages should be printed. Only used if selectionOnly is false.
toThe (1-based) page number to print to, used only if selectionOnly is false and from is >= 1

Default behaviour is SetPageRange(false,0)

Applies To

printing

SSee Also

HTML Printing with ScriptX

collatecopiesduplex

PageSetupPreviewPrintPrintSetup

SetPrintScale (v6.3.435 and later)


Description

Use this method to specify the scale to be used during printing - this is print scalingnot view zooming.

The IE 7 style template is required for this method to have any effect.

Syntax

printing.SetPrintScale(lScale,)

ParameterDescription
lScale

(Number) The print scale to use, expressed as a percentage. The value must be either -1 or between 30 and 999 or it will be ignored.

The special value -1 denotes 'scale to fit' where, if necessary, the content is scaled to fit the width of the paper - if scaling is not necessary to fit, 100% scaling is used.

Applies To

printing

Example

function startPreview() {
	var s = document.getElementById("selectScale");
	factory.printing.SetPrintScale(s.options[s.selectedIndex].value);
}

  

See Also

SetPreviewZoomtemplateUrl

 

SetPreviewZoom (v6.3.435 and later)


Description

Use this method to specify the Zoom to be used during print preview - this is view zooming, not print scaling.

Syntax

printing.SetPreviewZoom(lZoom,,pagesX,pagesY)

ParameterDescription
lZoom(Number) The Zoom scaling to use, either expressed as a percentage (e.g. 200 for double full size) or one of the following special values:
-1Zoom to show the full page width in the view.
-2Zoom to show the full page height in the view.
-3Zoom to show 2 full height pages in the view.
0Zoom to show full height pages, layed out as described by the pagesX and pagesY parameters (requires the IE 7 style template).
For the IE 6 and earlier style template, the default value is 75%. For IE 7 and later style template, the default value is -2.
pagesX (optional, requires the IE 7 style template)(Number) Only used with the IE 7 style template when lZoom is 0. Specifies the number of pages to display across the view (columns).
pagesY (optional, requires the IE 7 style template)(Number) Only used with the IE 7 style template when lZoom is 0. Specifies the number of rows of pages to display.

Applies To

printing

Example

function startPreview() {
	var z,x=0,y=0;

	if ( document.getElementById("selectTemplate").selectedIndex != 1 ) { // if not IE 7 template
		var s = document.getElementById("selectZoom");
		z = s.options[s.selectedIndex].value;
	}
	else {
		var s = document.getElementById("selectZoom");
		var s1 = document.getElementById("selectPages");

		var o = parseInt(s1.options[s1.selectedIndex].value);

		switch (o) {
			case 0: // zoomed one page
				z = s.options[s.selectedIndex].value;
				break;

			case 2: // the rest are multi-page views.
				z = 0;
				x = 2;
				y = 1;
				break;

			case 3:
				z = 0;
				x = 3;
				y = 1;
				break;

			case 6:
				z = 0;
				x = 3;
				y = 2;
				break;

			case 12:
				z = 0;
				x = 4;
				y = 3;
				break;

		}
	}

	factory.printing.SetPreviewZoom(z,x,y);
	factory.printing.Preview();
}

  

See Also

SetPrintScale

Sleep


Description

Suspends (sleeps) script execution for a specified timeout or until a passed callback function returns true. This is an efficient way to wait for an event without burning CPU cycles.

Syntax

printing.Sleep(timeout, [callback])

ParameterDescription
timeout(Number) the timeout in milliseconds.
callback(Function) the optional pointer to the function to be periodically called within the Sleep method.
When the function returns true, the sleep is canceled.

Return Value

Returns true if the sleep was canceled by a callback function.

Applies To

printing

Example

The following code snippet navigates a frame to a file then prints its content:

<script defer>
function NavigatePrintFrame(url) {
  idFrame.navigate(url);
  factory.printing.Sleep(100) // let the navigation start
  factory.printing.Sleep(1000*60, IsReady) // sleep for 1 minute or until the document is ready
  factory.printing.Print(true, idFrame)
}
function IsReady() {
  return idFrame.document.readyState == "complete"
}
</script>

See Also

HTML Printing with ScriptX

onafterprint

IsSpoolingPrintWaitForSpoolingComplete

WaitForSpoolingComplete


Description

Waits for all pending download and spooling operations originated with PrintPrintHTML/PrintXML and BatchPrintPDF calls to complete.WaitForSpoolingComplete provides visual feedback such as a modal window state and an hourglass cursor.

Syntax

printing.WaitForSpoolingComplete()

Return Value

Returns a boolean value indicating whether or not there are still outstanding unspooled downloads to be printed.

Example

Check out the source code of the ScriptX Techie Printing example.

<script defer>
function PrintAndGo() {
  if ( factory.printing.Print() )
    factory.printing.WaitForSpoolingComplete()
  window.close()
}
</script>

Applies To

printing

See Also

HTML Printing with ScriptX

onafterprintonbeforeunload

BatchPrintPDFIsSpoolingOwnQueuePrintPrintHTML,  Sleep


MeadCo's ScriptX, MaxiPT and the MeadCo Security Manager are Copyright (c) Mead & Co Limited, 1998-2008.

Microsoft, Windows, Internet Explorer are registered trademarks of Microsoft Corporation. All companies and product names mentioned are trademarks of the respective companies.

MeadCo ScriptX Control

Posted by 1010