数字印章现在越来越普及了,OA系统中的审批,比如请款,报销等,经常会用到数字印章。如何用 jatoolsPrinter打印这些单据?请参照以下代码:
复制内容到剪贴板
代码:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="guide.css" />
<script>
function doPrint(how) {
// 检索出所有印章对象
var doc = document.getElementById('printed').contentDocument;
var objects = doc.querySelectorAll('object');
var stamps = [];
for (var i = 0; i < objects.length; i++) {
var object = objects[i];
if (object.classid == "clsid:2294689C-9EDF-40BC-86AE-0438112CA439") {
var newid = "stamp-" + i;
object.id = newid;
stamps.push(object);
}
}
var myDoc = {
stamps : stamps, //传入有多个个印章需要打印
autoShrink : true, // 自动收缩打印
documents : doc,
copyrights : '杰创软件拥有版权 www.jatools.com'
};
var jatoolsPrinter = document.getElementById("jatoolsPrinter");
// 调用打印方法
if(how == '打印预览...')
jatoolsPrinter.printPreview(myDoc ); // 打印预览
else if(how == '打印...')
jatoolsPrinter.print(myDoc ,true); // 打印前弹出打印设置对话框
else
jatoolsPrinter.print(myDoc ,false); // 不弹出对话框打印
}
</script>
</head>
<body>
<input type="button" value="打印预览..." onClick="doPrint('打印预览...')">
<input type="button" value="打印..." onClick="doPrint('打印...')">
<input type="button" value="打印" onClick="doPrint('打印')"><br>
<br>
<iframe id='printed' src='bx.htm' style='border:none;width:100%;height:900px;'></iframe>
<object id="jatoolsPrinter" codebase="jatoolsPrinter.cab#version=5,4,0,0"
classid="clsid:B43D3361-D075-4BE2-87FE-057188254255" width="0" height="0">
</object>
</body>
</html>
1. 将被打印单据,放在一个iframe里面
2. 将单据里面的印章控件,即