February 2008 (Version 6.3.436 and later)
- 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
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 other 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 headers, footers, margins and 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 as basic.
With the releases of later versions, significantly more advanced printing functionality was introduced which is only accessible in the presence of a paid-for MeadCo publishing license.
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) with the exception of Windows NT 3.51.
ScriptX has been widely adopted and acknowledged by the Web and intranet development communities. Check out:
Feel free to investigate the source code from any of the examples and to cut & paste fragments into your own applications.
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).
A 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.
Custom Print Templates can be deployed (templateURL) in IE5.5 and later. Read more about MeadCo's in-depth support for Print Templates here.
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 (IsSpooling, WaitForSpoolingComplete, onafterprint). 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 (headersbasic, footersbasic, marginsbasic, paper orientationbasic, printer name, paper size, paper source, page range selection, number of copies, collation, duplex 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 now be trapped and cancelled, or handled in a particular way (disableUI, onuserprint, onuserpreview, onuserpagesetup). 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 and are automatically restored upon navigation, or when the window is closed.
A redirect of raw print-out data can be made to a specified file name (printToFileName).
Basic printing of Microsoft Officetm and Adobe Acrobattm documents.
Batch printing of PDF and MS Office documents (BatchPrintPDF).
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 6,3,436,14 and update smsx.cab (and replace ScriptX.cab with smsx.cab) on your servers.
An important compatibility issue is that ScriptX printing will now 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.
Version 6.2 introduces the printerControl, Jobs 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.
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 are not 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.
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:
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.
Finally, a number of problems have been resolved. A development history, as well as latest test versions of ScriptX is available on the ScriptX Beta page.
Before reading further, please have a look at our illustrative Basic, Advanced 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:
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.
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.
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 Computer, Local Intranet, Trusted Sites and Internet Security Zones.
In addition, on Windows 2000 systems and later, the user must be logged on as an Adminsitrator/Power User with the ability to write to the HKEY_LOCAL_MACHINE registry hive and the Windows system folder (typically c:\windows\system32).
If these conditions cannot be met, we suggest you review the Zeepe framework. The Zeepe framework includes ScriptX but is installed via Microsoft Windows Installer technology allowing the components to be installed by users or controlled as part of Corporate software distribution policies. Please note that the ScriptX software included with Zeepe is the same as the stand-alone product, but the ClsIds are changed. An option to only install the ScriptX components of the Zeepe framework is also available - i.e. installation of ScriptX via Windows Installer.
From the first 6,3,435,x version onwards, ScriptX comes in a single signed CAB - smsx.cab - which is part of a download package obtainable from the ScriptX 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 (6,3,436,14) 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 following code snippets assumes that smsx.cab exists in the same folder as the hosting page itself.
<object id=factory viewastext style="display:none" classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814" codebase="smsx.cab#Version=6,3,436,14"> </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.
NOTE: with the 'basic' subset, you can only script header, footer, page margins, paper orientation, Print and PageSetup methods and properties.
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=6,3,436,14"> <param name="template" value="MeadCo://IE7" /> </object>
The ability to specify a particular in-built template is included in the 'basic' subset.
<!-- MeadCo Security Manager -->
<object viewastext style="display:none"
classid="clsid:5445be81-b796-11d2-b931-002018654e2e"
codebase="smsx.cab#Version=6,3,436,14">
<param name="GUID" value="{C537EAE6-66B2-498D-A060-683068A29856}">
<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 {C537EAE6-66B2-498D-A060-683068A29856} 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
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=6,3,436,14">
<param name="GUID" value="{C537EAE6-66B2-498D-A060-683068A29856}">
<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>
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.
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.
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
Beyond Print Preview: Print Customization for Internet Explorer 5.5
Print Preview 2: The Continuing Adventures of Internet Explorer 5.5 Print Customization
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.
Bins, Forms, factory, printing, printerControl, Jobs, Job, rawPrinting
attributes, bottomMargin, collate, copies, currentPrinter, disableUI, duplex, fontColor, footer, header, isLocal, isNetwork, isShared, Jobs, leftMargin, location, name, onafterprint, onbeforeunload, onpagesetup, onuserpagesetup, onuserprint, onuserprintpreview, pageHeight, pageWidth, paperSize, paperSource, port, portrait, printBackground, printer, printer (direct printing), printerControl, printToFileName, rightMargin, serverName, shareName, status, templateURL, topMargin, unprintableBottom, unprintableLeft, unprintableRight, unprintableTop
BatchPrintPDF, Delete, DefaultPrinter, EnumJobs, EnumPrinters, GetJobsCount, GetMarginMeasure, IsSpooling, IsTemplateSupported, OwnQueue, PageSetup, Pause, Preview, Print, PrintDocument, PrintHTML, PrintPDF, PrintSetup, PrintString, Purge, Restart, Resume, SetMarginMeasure, SetPageRange, SetPrintScale, SetPreviewZoom, Sleep, WaitForSpoolingComplete
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 VBScript for..each loop).
The names returned are suitable for use with the paperSource property.
oJobs = printerControl.Bins
Item(nIndex) - returns the name of the paper source item at nIndex
Count - returns the number of available paper sources.
None.
<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>
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 VBScript for..each loop).
The names returned are suitable for use with the paperSize property.
oJobs = printerControl.Forms
Item(nIndex) - returns the name of the paper at nIndex
Count - returns the number of available paper sizes.
None.
<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>
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.
HTML page:
<object id=factory viewastext style="display:none" classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814" codebase="smsx.cab#Version=6,3,436,14"> </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 %>
Represents the printing functionality of ScriptX. See HTML Printing with ScriptX for more information and examples.
printing = factory.printing
bottomMargin, collate, copies, currentPrinter, disableUI, duplex, footer, header, leftMargin, onafterprint, onbeforeunload, onpagesetup, onuserpagesetup, onuserprint, onuserprintpreview, pageHeight, pageWidth, paperSize, paperSource, portrait, printBackground, printer, printToFileName, rightMargin, templateURL, topMargin, unprintableBottom, unprintableLeft, unprintableRight, unprintableTop
BatchPrintPDF, DefaultPrinter, DoPrint, EnumJobs, EnumPrinters, GetJobsCount, GetMarginMeasure, IsSpooling, IsTemplateSupported, OwnQueue, PageSetup, Preview, Print, PrintHTML, PrintPDF, PrintSetup, PrintXML, SetMarginMeasure, SetPageRange, SetPrintScale, SetPreviewZoom, Sleep, WaitForSpoolingComplete
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").
oControl = factory.printing.printerControl(sPrinterName)
attributes, Bins, Forms, isLocal, isNetwork, isShared, Jobs, location, name, port, serverName, shareName, status
<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>
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 printer, paper size, orientation, 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.
raw = factory.rawPrinting
printer
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).
oJobs = printerControl.Jobs
Item(nIndex) - returns a printJob object for the item at nIndex
Count - returns the number of items in the queue.
None.
<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>
Represents a single job in the queue for a printer. A job is obtained from the list of print jobs available on a printer.
oJob = printerControl.Jobs.Item(nIndex)
All properties are read only:
Property Descripion document Specifies the name of the print job, typically the title of the html document that has been printed. machineName Specifies the name of the machine that created the print job. pagesPrinted Specifies the number of pages that have printed. This value may be zero if the print job does not contain page delimiting information. position Specifies the job's position in the print queue. printerName Specifies the name of the printer for which the job is spooled. size Specifies the size, in bytes, of the job. status Specifies the job status, can be one or more of the following values:
Meaning Value JOB_STATUS_PAUSED 0x00000001 JOB_STATUS_ERROR 0x00000002 JOB_STATUS_DELETING 0x00000004 JOB_STATUS_SPOOLING 0x00000008 JOB_STATUS_PRINTING 0x00000010 JOB_STATUS_OFFLINE 0x00000020 JOB_STATUS_PAPEROUT 0x00000040 JOB_STATUS_PRINTED 0x00000080 JOB_STATUS_DELETED 0x00000100 JOB_STATUS_BLOCKED_DEVQ 0x00000200 JOB_STATUS_USER_INTERVENTION 0x00000400 JOB_STATUS_RESTART 0x00000800 statusText A 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. submittedAt Specifies the time when the job was submitted. totalPages Specifies the number of pages required for the job. This value may be zero if the print job does not contain page delimiting information. userName Specifies 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).
Returns the attributes of the printer; can be any reasonable combination of the following values:
Value Meaning 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.
attributes = printerControl.attributes
This is a read only property.
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.
printing.bottomMargin = numMargin
This is a read/write property.
Check out the source code of the ScriptX Advanced Printing and ScriptX Techie Printing examples.
leftMargin, pageHeight, pageWidth, portrait, rightMargin, topMargin, unprintableBottom, unprintableLeft, unprintableRight, unprintableTop
GetMarginMeasure, PageSetup, Print, PrintHTML, SetMarginMeasure
Specifies whether or not to collate the pages of HTML print-outs when more than one copy is printed.
printing.collate = true|false
This is a read/write property. Use true to collate.
Check out the source code of the ScriptX Techie Printing example.
Specifies the number of copies for HTML print-outs.
printing.copies = numCopies
This is a read/write property.
Check out the source code of the ScriptX Techie Printing example.
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.
printing.currentPrinter = sPrinterName
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.
The internal implementation of writing to the currentPrinter property is the same as writing to the printer property, other than the implementation of currentPrinter 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.
factory.printing.currentPrinter = "\\\\FS-LYS-01\\HP5n-759" // print to \\FS-LYS-01\HP5n-759
printer, EnumJobs, EnumPrinters, GetJobsCount, IsTemplateSupported, Print
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.
printing.disableUI = true|false
This is a read/write property.
Check out the source code of the ScriptX Advanced Printing example.
onpagesetup, onuserpagesetup, onuserprint, onuserprintpreview
Duplex mode (if supported by the targeted printer).
printing.duplex = number
This is a read/write property. Use 1 for simplex mode (no duplex), 2 for vertical duplex, 3 for horizontal duplex.
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.
printing.footer = sFooter
This is a read/write property.
Check out the source code of the ScriptX Advanced Printing and ScriptX Techie Printing examples.
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:
Shorthand Meaning &w Window title &u Page address (URL) &d Date in short format (as specified by Regional Settings in Control Panel) &D Date in long format (as specified by Regional Settings in Control Panel) &t Time in the format specified by Regional Settings in Control Panel &T Time in 24-hour format &p Current page number &P Total number of pages && A single ampersand (&) &b The text immediately following these characters as centered. &b&b The text immediately following the first "&b" as centered, and the text following the second "&b" as right-justified.
printing.header = sHead
This is a read/write property.
Check out the source code of the ScriptX Advanced Printing and ScriptX Techie Printing examples.
Returns whether the printer is a local printer (true) or not (false). isLocal tests whether PRINTER_ATTRIBUTE_LOCAL is set in the attributes.
bIs = printerControl.isLocal
This is a read only property.
Returns whether the printer is a network printer (true) or not (false). isNetwork tests whether PRINTER_ATTRIBUTE_NETWORK is set in the attributes.
bIs = printerControl.isNetwork
This is a read only property.
Returns whether the printer is a shared printer (true) or not (false). isShared tests whether PRINTER_ATTRIBUTE_SHARED is set in the attributes.
bIs = printerControl.isShared
This is a read only property.
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.
printing.leftMargin = numMargin
This is a read/write property.
Check out the source code of the ScriptX Advanced Printing and ScriptX Techie Printing examples.
pageHeight, pageWidth, portrait, rightMargin, topMargin, unprintableBottom, unprintableLeft, unprintableRight, unprintableTop
GetMarginMeasure, PageSetup, Print, PrintHTML, SetMarginMeasure
Returns a string describing the physical location of the printer.
sLoc = printerControl.location
This is a read only property.
Returns a string giving the name of the printer.
sName = printerControl.name
This is a read only property.
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 Techniques, Using CSS to specify alternate document to print out.
printing.onafterprint = function_object
This is a read/write property.
<script defer>
factory.printing.onafterprint = AfterPrint;
function AfterPrint() {
alert("The document has been sent to the print spooler!");
}
</script>
onpagesetup, onuserpagesetup, onuserprint, onuserprintpreview
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.
printing.onbeforeunload = string
This is a read/write property.
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.
printing.onpagesetup = function_object
This is a read/write property.
Check out the source code of the ScriptX Techie Printing example.
disableUI, onafterprint, onuserpagesetup, onuserprint, onuserprintpreview
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.
printing.onuserpagesetup = function_object
This is a read/write property.
Check out the source code of the ScriptX Techie Printing example.
disableUI, onafterprint, onpagesetup, onuserprint, onuserprintpreview
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.
printing.onuserprint = function_object
This is a read/write property.
Check out the source code of the ScriptX Techie Printing example.
disableUI, onafterprint, onpagesetup, onuserpagesetup, onuserprintpreview
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.
printing.onuserprintpreview = function_object
This is a read/write property.
Check out the source code of the ScriptX Techie Printing example.
disableUI, onafterprint, onpagesetup, onuserpagesetup, onuserprint
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.
height = printing.pageHeight
This is a read-only property.
Check out the source code of the ScriptX Techie Printing example.
bottomMargin, leftMargin, pageWidth, paperSize, portrait, rightMargin, topMargin, unprintableBottom, unprintableLeft, unprintableRight, unprintableTop
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.
width = printing.pageWidth
This is a read-only property.
Check out the source code of the ScriptX Techie Printing example.
bottomMargin, leftMargin, pageHeight, paperSize, portrait, rightMargin, topMargin, unprintableBottom, unprintableLeft, unprintableRight, unprintableTop
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.
printing.paperSize = sPaperSize
This is a read/write property.
Check out the source code of the ScriptX Techie Printing example.
Forms, pageHeight, pageWidth, paperSource, portrait, unprintableBottom, unprintableLeft, unprintableRight, unprintableTop
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.
printing.paperSource = sPaperSource
This is a read/write property.
Check out the source code of the ScriptX Techie Printing example.
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.
sName = printerControl.port
This is a read only property.
Specifies the page orientation for HTML print-outs.
The portrait property is part of the basic freely-distributable printing subset.
printing.portrait = true|false
This is a read/write property. Use true to specify portrait and false for landscape.
Check out the source code of the ScriptX Techie Printing example.
bottomMargin, leftMargin, pageHeight, pageWidth, paperSize, templateURL, topMargin, unprintableBottom, unprintableLeft, unprintableRight, unprintableTop
Specifies whether or not to print a page's background colors and images.
printing.printBackground = true|false
This is a write-only property.
Check out the source code of the ScriptX Techie Printing example.
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.
printing.printer = sPrinterName
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.
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.
bottomMargin,collate, copies, currentPrinter, duplex, footer, header, leftMargin, paperSize, paperSource, portrait, printBackground, printToFileName, rightMargin, templateURL, topMargin
DefaultPrinter, EnumJobs, EnumPrinters, GetJobsCount, IsSpooling, IsTemplateSupported, PrintHTML, PrintSetup, SetPageRange, WaitForSpoolingComplete
Specifies the printer to directly print to. Only the exact printer name strings as they appear in the Printers Control Panel may be used.
rawPrinting.printer = sPrinterName
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.
factory.rawPrinting.printer = "Zebra LP2844-Z"
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.
printing.printToFileName = sPathFileName
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.
factory.printing.printToFileName = "d:\\temp\\printout.prn"
IsSpooling, Print, PrintHTML, PrintSetup, WaitForSpoolingComplete
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.
printing.rightMargin = numMargin
This is a read/write property.
Check out the source code of the ScriptX Advanced Printing and ScriptX Techie Printing examples.
pageHeight, pageWidth, portrait, leftMargin, topMargin, unprintableBottom, unprintableLeft, unprintableRight, unprintableTop
GetMarginMeasure, PageSetup, Print, PrintHTML, SetMarginMeasure
Returns a string giving the name of the server computer controlling the printer. If the string is empty then the printer is controlled locally.
sName = printerControl.serverName
This is a read only property.
Returns a string identifying the share point of the printer. This value is only present if PRINTER_ATTRIBUTE_SHARED is set on attributes.
sName = printerControl.shareName
This is a read only property.
Specifies the status of the printer, it can be any reasonable combination of the following values.
Value Meaning 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.
printerControl.status = nStatus
This is a read/write property. The user will require printer administrator writes in order to update the status.
Specifies the URL of a custom Print Template for Internet Explorer 5.5 or later. Internet Explorer will use the specified template for all its printing operations.For ScriptX v6.3 and later, this property is also available as basic property, provided the value set is one of the following special values
Value Description MeadCo://IE55 The IE 5.5/IE 6 style template - note can be used on IE 7. MeadCo://IE7 The IE 7 style template - note free usage on all versions of IE 5.5 or later. MeadCo://Default The default template for the IE version in use, i.e. the template matches the browser version. This is the default behaviour. MeadCo://maxipt The MaxiPT template (requires a license). If you use your own templates with ScriptX, make sure that you insert a MeadCo's TriPrint Helper <OBJECT> into the <HEAD> section of the print template source:
<HTML XMLNS:IE> <HEAD> <?IMPORT namespace="ie" implementation="#default"> <!-- <TriPrint> (c) 2000, 2001 by Mead & Co Limited <triprint@meadroid.com> --> <object classid="clsid:1663ed6a-23eb-11d2-b92f-008048fdd814" viewastext> <param name="__PX__template" value="true"> </object> <!-- </TriPrint> --> <TITLE>Print Preview</TITLE>
printing.templateURL = templateURL
This is a read/write property.
Read more about MeadCo's in-depth support for Print Templates.
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.
printing.topMargin = numMargin
This is a read/write property.
Check out the source code of the ScriptX Advanced Printing and ScriptX Techie Printing examples.
leftMargin, pageHeight, pageWidth, portrait, rightMargin, bottomMargin, unprintableBottom, unprintableLeft, unprintableRight, unprintableTop
GetMarginMeasure, PageSetup, Print, PrintHTML, SetMarginMeasure
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.
numMargin = printing.unprintableBottom
This is a read/only property.
bottomMargin, leftMargin, pageHeight, pageWidth, paperSize, topMargin, unprintableLeft, unprintableRight, unprintableTop
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.
numMargin = printing.unprintableLeft
This is a read/only property.
bottomMargin, leftMargin, pageHeight, pageWidth, paperSize, topMargin, unprintableBottom, unprintableRight, unprintableTop
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.
numMargin = printing.unprintableRight
This is a read/only property.
bottomMargin, leftMargin, pageHeight, pageWidth, paperSize, topMargin, unprintableBottom, unprintableLeft, unprintableTop
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.
numMargin = printing.unprintableTop
This is a read/only property.
bottomMargin, leftMargin, pageHeight, pageWidth, paperSize, topMargin, unprintableBottom, unprintableLeft, unprintableRight
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. As of the present release of ScriptX, BatchPrintPDF prints only on the default printer using default settings.
To print PDF files, the Adobe Acrobat Readertm 4.0 or later should be present on the client system. It can be freely downloaded from the Adobe website.
Please note: This method uses DDE to converse with Adobe Acrobat Readertm and is known to work well with Adobe Acrobat Readertm versions 4 and 5 - problems may be encountered with Adobe Acrobat Readertm 6 (due to security restrictions introduced in Adobe Acrobat Readertm v6 it is possible for the user to [accidentally] disable printing altogether) and problems will almost certainly be encountered with Adobe Acrobat Readertm 7 and later to the extent that printing does not work at all or is intermittent. In other words, for v6 and later "your mileage may vary". We strongly recommend that if you intend to use this functionality of ScriptX you obtain an evaluation license and test your usage scenarios very carefully.
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.
printing.BatchPrintPDF(url)
Here is a basic example of BatchPrintPDF use
<body> <!-- MeadCo Security Manager - using evaluation license --> <object viewastext style="display:none" classid="clsid:5445be81-b796-11d2-b931-002018654e2e" codebase="smsx.cab#Version=6,3,436,14"> <param name="GUID" value="{C537EAE6-66B2-498D-A060-683068A29856}"> <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 BatchPrintPDF(url) { factory.printing.BatchPrintPDF(url); } </script> <input id=idPrint disabled type="button" value="PrintHTML('info.htm')" onclick="BatchPrintPDF('report.pdf')"> </body>
DefaultPrinter, EnumJobs, EnumPrinters, GetJobsCount, IsSpooling, PrintHTML, PrintPDF, Sleep, WaitForSpoolingComplete
Returns the name of the default printer (if any).
printerName = printing.DefaultPrinter()
EnumJobs, EnumPrinters, GetJobsCount, IsTemplateSupported, Print
The alias for the Print method (retained for compatibility reasons).
Enumerates active jobs on the given printer.
var jobName = {}
status = printing.EnumJobs(printerName, index, jobName)
Parameter Description 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])
Returns a numeric value indicating the current status of the job. The bits have the following meaning:
Meaning Value JOB_STATUS_PAUSED 0x00000001 JOB_STATUS_ERROR 0x00000002 JOB_STATUS_DELETING 0x00000004 JOB_STATUS_SPOOLING 0x00000008 JOB_STATUS_PRINTING 0x00000010 JOB_STATUS_OFFLINE 0x00000020 JOB_STATUS_PAPEROUT 0x00000040 JOB_STATUS_PRINTED 0x00000080 JOB_STATUS_DELETED 0x000001