打印方法
function PrintPage() {
try {
if (testPrintContorl()) {
hideNoPrintElement();
factory.printing.Print(false); //设置为false,直接打印
showNoPrintElement();
} else {
return false;
}
} catch (e) {
alert("打印出错,请确定使用的是IE浏览器!\n请确定已经安装打印机并正确的链接到打印机!");
showNoPrintElement();
}
}
function SetPrintSettings() {
if(testPrintContorl()) {
factory.printing.header = "";
factory.printing.footer = "";
factory.printing.portrait = true; //方向,true
factory.printing.leftMargin = 0.3; //mm
factory.printing.topMargin = 0.3;
factory.printing.rightMargin = 0.3;
factory.printing.bottomMargin = 0.3;
} else {
return false;
}
}
function CallPrintSetUp() {
if (testPrintContorl()) {
factory.printing.PageSetup();
} else {
return false;
}
}
function CallPrintPrivew() {
if(testPrintContorl()) {
factory.printing.Preview();
} else {
return false;
}
}
function moveBackClick() {
var rootPage = parent.parent;
if(rootPage == null) {
history.back();
} else {
try {
rootPage.GB_hide();
} catch(ex) {
history.back();
}
}
}
function testPrintContorl() {
if (!factory.object) {
if (confirm("页面打印控件还没有安装!\n请点击确定转到安装页面")) {
window.open("../PrintControl/PrintControlSetUpInfo.htm", "_self");
//window.open("../PrintControl/smsx.exe","width=100,height=200,toolbar=no,scrollbars=no,menubar=no,screenX=100,screenY=100");
}
return false;
} else {
return true;
}
}
function hideNoPrintElement() {
var nph = document.getElementById("NoPrint");
if (null != nph) {
nph.style.display = "none";
}
}
function showNoPrintElement() {
var nph = document.getElementById("NoPrint");
if (null != nph) {
nph.style.display = "";
}
}
function initPage() {
if (testPrintContorl()) {
SetPrintSettings();
} else {
return false;
}
}
window.onload = initPage;
使用的控件
<object id="factory" style="display:none" classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814" codebase="../PrintControl/smsx.cab#Version=6,3,435,20">
<param name="template" value="MeadCo://IE7" />
</object>