In the files that came with the printer driver I found the following snippet, unfortunately without any instructions of how to work with it:
<PAGE LENGTH (INCHES)>
Sets page length in inches.
Name: ESC C 0 n (~n = 1 to 22~)DEC
Dec.: 27 67 0 n
Hex.: 1B 43 00 n
Comments:
*Upon receipt of ESC+C+0+n, the present line position becomes
the top of form position.
I just don’t know what to do with this information and how to send it to the printer. I tried to change the settings through a generic driver, sending the Hex.:“<1B><C><0><1>” but this did not work consistently and did not do what I intendet. I also tried “ESC+C+0+1”, “95” and other variations. Thats when I looked for other ways and what I have found are functions like:
function custom_print() {
if (document.all) {
if (navigator.appVersion.indexOf("5.0") == -1) {
var OLECMDID_PRINT = 6;
var OLECMDEXECOPT_DONTPROMPTUSER = 2;
var WebBrowser = '<OBJECT ID=\\"WebBrowser1\\" WIDTH=0 HEIGHT=0 CLASSID=\\"CLSID:8856F961-340A-11D0-A96B-00C04FD705A2\\"></OBJECT>';
document.body.insertAdjacentHTML("beforeEnd", WebBrowser);
WebBrowser1.ExecWB(OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER, 1);
WebBrowser1.outerHTML = "";
} else {
self.print();
}
} else {
WebBrowser1.IOleCommandTarget.Exec(OLECMDID_PRINT ,OLECMDEXECOPT_DONTPROMPTUSER,1,"","");
WebBrowser1.outerHTML = "";
}
}
This is supposed to print the page without any prompt from the user. (Strangely this only works with the VB version but not the javascript version)
Or this code wich sets the margins and orientation:
var shell = new ActiveXObject("WScript.Shell");
function SetPrintProperties() {
try {
window.setTimeout("javascript:shell.SendKeys('%fu');",1000);
window.setTimeout("javascript:SetPaper();", 1000);
} catch (e) {
alert ("An exception occured: " + e + "\
Code is: " + e.number + "\
Description is: " + e.description);
alert('Please verify that your print settings have a Landscape orientation and minimum margins.');
}
}
function SetPaper() {
shell.sendKeys("%a{TAB}.2{TAB}0{TAB}0{TAB}0{ENTER}");
}
or this setting the header and footer:
var HKEY_Root, HKEY_Path, HKEY_Key;
HKEY_Root = "HKEY_CURRENT_USER";
HKEY_Path = "\\\\Software\\\\Microsoft\\\\Internet Explorer\\\\PageSetup\\\\";
// Set the page footer to print the header is empty
function PageSetup_Null (){
try{
var Wsh = new ActiveXObject("WScript.Shell");
HKEY_Key = "header";
Wsh.RegWrite (HKEY_Root + HKEY_Path + HKEY_Key ,"");
HKEY_Key = "footer";
Wsh.RegWrite (HKEY_Root + HKEY_Path + HKEY_Key ,"");
}catch (e) {}
}
// Set the page footer to print the header for the default value
function PageSetup_Default (){
try{
var Wsh = new ActiveXObject ( "WScript.Shell");
HKEY_Key = "header";
Wsh.RegWrite (HKEY_Root + HKEY_Path + HKEY_Key, "& w & b on page 00 yards, & p / & P");
HKEY_Key = "footer";
Wsh.RegWrite (HKEY_Root + HKEY_Path + HKEY_Key, "& u & b & d");
}
catch (e) {}
}
So there is some way of influencing the printer, I just can’t figure out how to tell it what I want it to do but I am sure that there must be a way.
My page will not be public but just on the pc connected to the printer so I could make it a .hta page to loosen the security constrains.