October 2003
MeadCo's ScriptX is a non-visual downloadable ActiveX control, developed to provide absolute control over document printing operations from client and server computers running Microsoft's Internet Explorer browser. ScriptX became well know for its HTML printing capabilties following publication of our article Scripting Support for Web Page Printing» on the MSDN website.
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 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.
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 Internet Explorer versions 4.01 SP1 - 6.0 SP1 on all Microsoft Windows Win32 OS platforms with the exception of Windows NT 3.51.
ScriptX has been widely adopted and acknowledged by the Web and intranet development communities. Check out the following references:
Feel free to investigate the source code from any of the examples and to cut & paste fragments into your own applications.
ScriptX extends basic printing functionality with some powerful features which can only be deployed in the presence of a paid-for publishing license. Some of these 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.
A PrintHTML method to print one or more externally-located HTML documents. PrintHTML can also be used to implement server side printing.
All Internet Explorer versions from IE 4.01 SP1 onwards are fully supported. Custom Print Templates can now 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 hosted in frames.
Batch printing of PDF and MS Office documents (BatchPrintPDF).
The current version of ScriptX is backwards compatible and will work with all existing publishing licenses. A number of issues have been resolved since earlier versions, including full support for all versions of Internet Explorer up to 6.0 SP1 + all patches.
We strongly recommend that you update your <OBJECT> elements to reference the current version 6,1,431,2 and update the ScriptX.cab or smsx.cab files 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.
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.
ScriptX can be deployed either on client-side HTML or XML pages, or from server-side script.
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» security schema.
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.
ScriptX is installed from one of two signed CABs: ScriptX.cab for freely-distributable 'basic' deployment or smsx.cab for fully-functional licensed use. Both are part of a download package obtainable from the ScriptX site. The appropriate 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 script 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,1,431,2) 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 folowing code snippets assume that ScriptX.cab or smsx.cab exists in the same folder as the hosting page itself.
ScriptX.cab contains the same ScriptX binaries as smsx.cab but - because the 'basic' printing subset does not need to refer to a publishing license - it excludes the Security Manager component:
<object id=factory viewastext style="display:none" classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814" codebase="ScriptX.cab#Version=6,1,431,2"> </object>
The Basic printing example illustrates the use of the ScriptX.cab.
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.
smsx.cab contains both the ScriptX and the Security Manager binaries required to publish fully-functional licensed content:
<!-- MeadCo Security Manager --> <object viewastext style="display:none" classid="clsid:5445be81-b796-11d2-b931-002018654e2e" codebase="smsx.cab#Version=6,1,431,2"> <param name="GUID" value="{87530A67-6E2E-4991-8D2D-6F0208414B4B}"> <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 {87530A67-6E2E-4991-8D2D-6F0208414B4B} 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
The following technique can be applied to the use of both ScriptX.cab and smsx.cab. 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,1,431,2"> <param name="GUID" value="{87530A67-6E2E-4991-8D2D-6F0208414B4B}"> <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.
Microsoft Support Knowledge Base articles on Internet Explorer Printing»
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»
Scripting Support for Web Page Printing»
Printing with the Internet Explorer WebBrowser Control»
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».
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, Sleep, WaitForSpoolingComplete
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="ScriptX.cab#Version=6,1,431,2"> </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, EnumJobs, EnumPrinters, GetJobsCount, GetMarginMeasure, IsSpooling, IsTemplateSupported, OwnQueue, PageSetup, Preview, Print, PrintHTML, PrintPDF, PrintSetup, PrintXML, SetMarginMeasure, SetPageRange, Sleep, WaitForSpoolingComplete
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.
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
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.
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.
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
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
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.If you use your own templates with ScriptX 5.5, 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».
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,1,431,2"> <param name="GUID" value="{87530A67-6E2E-4991-8D2D-6F0208414B4B}"> <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 0x00000100 JOB_STATUS_BLOCKED_DEVQ 0x00000200 JOB_STATUS_USER_INTERVENTION 0x00000400 JOB_STATUS_RESTART 0x00000800
<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>
Enumerates locally-available printers.
printerName = printing.EnumPrinters(index)
Parameter Description index (Number) Zero-based index of the printer. Increment this value for each new EnumPrinters call
Returns the string name of the next printer. An empty value means that enumeration is over.
<!-- MeadCo Security Manager - using evaluation license --> <object viewastext style="display:none" classid="clsid:5445be81-b796-11d2-b931-002018654e2e" codebase="smsx.cab#Version=6,1,431,2"> <param name="GUID" value="{87530A67-6E2E-4991-8D2D-6F0208414B4B}"> <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>
DefaultPrinter, EnumJobs, EnumPrinters, GetJobsCount, Print, PrintSetup
Returns the number of printing jobs for the specified printer.
numJobs = printing.GetJobsCount(printer)
Returns a numeric value.
Returns current units of measure for print-out margins, either millimeters or inches. Use SetMarginMeasure to switch the default units.
units = printing.GetMarginMeasure()
Returns the currently-set units of measure. 1 stands for millimeters, 2 for inches.
Check out the source code of the ScriptX Advanced Printing and ScriptX Techie Printing examples.
bottomMargin, leftMargin, pageHeight, pageWidth, rightMargin, templateURL, topMargin, unprintableBottom, unprintableLeft, unprintableRight, unprintableTop
Checks if spooling is in progress as result of a Print call, or for any downloads outstanding in the queue created by PrintHTML, PrintXML or BatchPrintPDF 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.
isSpooling = printing.IsSpooling()
Returns a boolean value indicating whether or not there are still outstanding unspooled downloads to be printed
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>
BatchPrintPDF, OwnQueue, Print, PrintHTML, PrintXML, Sleep, WaitForSpoolingComplete
Checks whether or not Print Templates» are supported on the end user's system (i.e. checks for Internet Explorer 5.5 or later).
isTemplateSupported = printing.IsTemplateSupported()
Returns a boolean value indicating whether or not Print Templates are supported.
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.
printing.OwnQueue()
Invokes the standard Internet Explorer Page Setup... dialog. If the user closes the dialog with the OK button, current settings will be updated and an onpagesetup event will be fired.
The PageSetup method is part of the basic freely-distributable printing subset.
result = printing.PageSetup()
Returns a boolean value indicating whether or not a user has closed the dialog with the OK button.
Check out the source code of the ScriptX Advanced Printing and ScriptX Techie Printing examples.
bottomMargin, disableUI, footer, header, leftMargin, onpagesetup, onuserpagesetup, paperSize, paperSource, portrait, rightMargin, topMargin
Invokes the Print Preview... pane in Internet Explorer 5.5 and later.
The Preview method is part of the basic freely-distributable printing subset.
printing.Preview()
Check out the source code of the ScriptX Advanced Printing and ScriptX Techie Printing examples.
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 copies, duplex, paperSize, printBackground etc., target specific printer or print externally-located documents with PrintHTML. See HTML Printing with ScriptX for more info.
printing.Print([prompt[, frameOrWindow]])
Parameter Description 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
Returns false if printing with a prompt and the user cancels the printing.
Check out the source code of the ScriptX Basic, Advanced 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=6,1,431,2"> <param name="GUID" value="{87530A67-6E2E-4991-8D2D-6F0208414B4B}"> <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>
bottomMargin, collate, copies, duplex, footer, header, leftMargin, onafterprint, onuserprint, paperSize, paperSource, portrait, printBackground, printer, printToFileName, rightMargin, templateURL, topMargin
DefaultPrinter, EnumJobs, EnumPrinters, GetJobsCount, GetMarginMeasure, IsSpooling, IsTemplateSupported, OwnQueue, PageSetup, Preview, Print, PrintHTML, PrintPDF, PrintSetup, PrintXML, SetMarginMeasure, SetPageRange, WaitForSpoolingComplete
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.
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.
printing.PrintHTML(url[, prompt = false])
Parameter Description url (String) URL/html text to print:
Protocol Prints 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. prompt (Bool) Specifies whether or not the user should be prompted before the download is queued
Returns false if printing with a prompt and the user cancels the printing.
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=6,1,431,2"> <param name="GUID" value="{87530A67-6E2E-4991-8D2D-6F0208414B4B}"> <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=6,1,431,2"> <param name="GUID" value="{87530A67-6E2E-4991-8D2D-6F0208414B4B}"> <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='http://www.meadroid.com/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>
bottomMargin, collate, copies, duplex, footer, header, leftMargin, onafterprint, onuserprint, paperSize, paperSource, portrait, printBackground, printer, printToFileName, rightMargin, templateURL, topMargin
BatchPrintPDF, IsSpooling, OwnQueue, PageSetup, Print, PrintSetup, PrintXML, WaitForSpoolingComplete
Prints a document's inline PDF content. The HTML page should host an instance of the Adobe Acrobat Readertm ActiveX control that loads the PDF file. The control is a part Adobe Acrobat Readertm 4.0 or later which can be freely downloaded from the Adobe website».
As of the present release of ScriptX, PrintPDF prints only on the default printer using default settings.
printing.PrintPDF(idPDF[, prompt = true[, shrinkToFit = true [, from = -1[, to = -1]]]);
Parameter Description idPDF (Object) id of the Adobe Acrobat Reader control hosted on the same document or frame
as shown in the example belowprompt (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
Returns a boolean value indicating whether or not there are still outstanding downloads to be printed.
<body> <!-- MeadCo Security Manager - using evaluation license --> <object viewastext style="display:none" classid="clsid:5445be81-b796-11d2-b931-002018654e2e" codebase="smsx.cab#Version=6,1,431,2"> <param name="GUID" value="{87530A67-6E2E-4991-8D2D-6F0208414B4B}"> <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> <!-- Adobe Acrobat Readertm ActiveX Control --> <object id=idPDF width=50% height=50% classid="clsid:CA8A9780-280D-11CF-A24D-444553540000"> <param name="src" value="ReadMe.pdf"> </object> <script defer> function window.onload() { idPrint.disabled = false; } function PrintPDF(url) { factory.printing.PrintPDF(idPDF); } </script> <input id=idPrint disabled type="button" value="Print the PDF" onclick="PrintPDF()"> </body>
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.
result = printing.PrintSetup()
Returns a boolean value indicating whether or not the user has closed the dialog with the OK button.
Check out the source code of the ScriptX Advanced Printing and ScriptX Techie Printing examples.
collate, copies, disableUI, duplex, printer, printToFileName
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.
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=6,1,431,2"> <param name="GUID" value="{87530A67-6E2E-4991-8D2D-6F0208414B4B}"> <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>
bottomMargin, collate, copies, duplex, footer, header, leftMargin, onafterprint, onuserprint, paperSize, paperSource, portrait, printBackground, printer, printToFileName, rightMargin, templateURL, topMargin
BatchPrintPDF, IsSpooling, OwnQueue, PageSetup, Print, PrintHTML, PrintSetup, WaitForSpoolingComplete
Sets the units of measure for print-out margins.
printing.SetMarginMeasure(units)
Parameter Description units (Number) 1 stands for millimeters, 2 for inches.
Check out the source code of the ScriptX Advanced Printing and ScriptX Techie Printing examples.
bottomMargin, leftMargin, pageHeight, pageWidth, paperSize, rightMargin, topMargin, unprintableBottom, unprintableLeft, unprintableRight, unprintableTop
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 1.0» 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.
printing.SetPageRange(selectionOnly[, from, to])
Parameter Description selectionOnly (Bool) print the highlighted HTML selection only from (Number) print from the page, 1-based. Use 0 to print all pages to (Number) print to the page, 1-based
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.
Parameter Description 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.
Returns true if the sleep was canceled by a callback function.
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>
Waits for all pending download and spooling operations originated with Print, PrintHTML/PrintXML and BatchPrintPDF calls to complete. WaitForSpoolingComplete provides visual feedback such as a modal window state and an hourglass cursor.
printing.WaitForSpoolingComplete()
Returns a boolean value indicating whether or not there are still outstanding unspooled downloads to be printed.
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>
BatchPrintPDF, IsSpooling, OwnQueue, Print, PrintHTML, Sleep
MeadCo's ScriptX, MaxiPT and the MeadCo Security Manager are Copyright (c) Mead & Co Limited, 1998-2003.
Microsoft, Windows, Internet Explorer are registered trademarks of Microsoft Corporation. All companies and product names mentioned are trademarks of the respective companies.