PrintHTMLEx
Description (requires ScriptX v7 or later)
This method is an enhanced version of PrintHTML.
Prints either specified HTML text or the HTML 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. Notifications are sent to the supplied callback function to give details on progress of processing.
Important note: The HTML to be printed must not be ‘ScriptX-enabled’ - it must not contain an object tag referencing the ScriptX object nor script code that uses that object. Attempting to print HTML (either specified HTML text or a document specified by url) that contains the ScriptX object can lead to strange errors and failure of the entire printing process, including causing Internet Explorer to stop responding.
PrintHTMLEx should not be used with OwnQueue.
Syntax
printing.PrintHTML(url, prompt, callback, callbackdata)
Returns false if printing with a prompt and the user cancels the printing.
Parameter | Description | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
url |
(String) URL/HTML text to print:
|
||||||||||||||||||
prompt | (Bool) Specifies whether or not the user should be prompted before the download is queued | ||||||||||||||||||
callback |
Specifies the function to call when various events occur during the processing of the queue entry.
Syntax: callback(status, statusData, callbackdata)
|
||||||||||||||||||
callbackdata | Specifies the data to pass to the callback function. |
Support for "Modern" standards (aka Edge where "Edge" is the IE 11 definition).
Version 8.2 introduces the following:
-
When printing a downloaded document if the host document is in IE 11 edge mode then printHtml() will be enabled to print modern content. If the document does not print properly then change the host document to use an older document mode and printHtml() will then use the pre ScriptX 8 way of working, alternatively:
-
The use of pre ScriptX 8 behaviour can be forced using the url4:// pseudo protocol.
-
-
When printing dynamic content using the html:// pseudo protocol then the pre ScriptX way of working will be used unless the dynamic content starts with <!DOCTYPE html>, or:
- The support of modern standards can be forced using the html5:// pseudo protocol.
- The use of pre ScriptX 8 behaviour can be forced using the html4:// pseudo protocol.
Please note that all jobs in a queue will use the same mode of working. The mode can be changed if the queue is empty. The PrintHtmlEx callback on a job being queued will report the mode of the queue.
Examples
Check out a ScriptX printHTMLEx sample.
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=8,3,0,4">
<param name="GUID" value="{3cfd70e2-f38f-4ab2-95f4-4ce4c1e39497}">
<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 window.onload() {
idPrint.disabled = false;
}
function log(s) {
// use of jquery ...
$("#logoutput").append(s + "<br />");
}
function jobProgress(status, statusData, myData) {
switch (status) {
case 1:
log("Job: " + myData + " has been queued");
break;
case 2:
log("Job: " + myData + " has started");
break;
case 3:
log("Job: " + myData + " has started downloading: " + statusData);
break;
case 4:
log("Job: " + myData + " has downloaded: " + statusData);
break;
case 5:
log("Job: " + myData + " is printing");
break;
case 6:
log("Job: " + myData + " has completed");
break;
case -1:
log("Job: " + myData + " has an error: [" + statusData + "]");
break;
case -2:
log("Job: " + myData + " is being abandoned");
break;
default:
log("Job: " + myData + " unknown status: " + status);
break;
}
}
function PrintHTMLEx(url) {
factory.printing.PrintHTMLEx(url, false, jobProgress, 1);
}
</script>
<input id=idPrint disabled type="button" value="PrintHTMLEx('info.htm')"
onclick="PrintHTMLEx('info.htm')">
<div>
<p>Log:</p>
<div style="width:80%; font-size:80%" id="logoutput">