printDocument
Description
Loads the specified file and sends the content directly to the printer. The file bytes are not rendered in any way, they are sent to the printer for the printer to interpret. In this way, postscript can be sent directly to the printer or label printing commands.
This method is synchronous; it will not return until the file load and print is complete.
Syntax
rawPrinting.printDocument(url)
Parameter | Description |
---|---|
url |
(String) url of the file whose contents are to be sent to the printer. The url must be a fully qualified
url which can be obtained using the factory.baseUrl method - for example:
rawPrinting.printDocument(factory.baseUrl(sRelativeUrl))
|
Example
The following simple but complete example shows how to print a label stored on the web server to a Zebra printer. The sample asssumes that some process has run on the server to generate and store the required label.
<head>
<!-- MeadCo Security Manager - using evaluation license -->
;<bject 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 defer>
function printLabel() {
var p = factory.rawPrinting;
// select the Zebra printer
p.printer = "Zebra LP2844-Z"
// must give the full url of the file...
// The printDocument method is synchronous
p.printDocument(factory.baseURL("label.txt"));
}
</script>
</head>