asp.net调用Lodop实现页面打印或局部打印,可进行打印设置或预览

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="WebPrint.aspx.cs" Inherits="WebPrint" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Lodop打印</title>
<script type="text/javascript" language="javascript" src="LodopFuncs.js"></script>
<object id="LODOP_OB" classid="clsid:2105C259-1E0C-4534-8141-A753534CB4CA" width=0 height=0>
<embed id="LODOP_EM" type="application/x-print-lodop" width=0 height=0></embed>
</object>
<script language="javascript" type="text/javascript">
function CheckIsInstall() {
try {
var LODOP = getLodop(document.getElementById('LODOP_OB'), document.getElementById('LODOP_EM'));
if ((LODOP != null) && (typeof (LODOP.VERSION) != "undefined")) alert("本机已成功安装过Lodop控件!\n 版本号:" + LODOP.VERSION);
} catch (err) {
//alert("Error:本机未安装或需要升级!");
}
};
</script>
<script language="javascript" type="text/javascript">
var LODOP; //声明为全局变量
function prn1_preview() {
CreateOneFormPage();
LODOP.PREVIEW();
};
function prn1_print() {
CreateOneFormPage();
LODOP.PRINT();
};
function prn1_printA() {
CreateOneFormPage();
LODOP.PRINTA();
};
function CreateOneFormPage(){
LODOP=getLodop(document.getElementById('LODOP_OB'),document.getElementById('LODOP_EM'));
LODOP.PRINT_INIT("打印控件功能演示_Lodop功能_表单一");
LODOP.SET_PRINT_STYLE("FontSize",18);
LODOP.SET_PRINT_STYLE("Bold",1);
LODOP.ADD_PRINT_TEXT(50,231,260,39,"打印页面部分内容");
LODOP.ADD_PRINT_HTM(88, 200, 350, 600, document.getElementById("divprint").innerHTML);
};
</script>
</head>
<body> <form id="form1" runat="server">
<div>
测试一下:<a href="javascript:CheckIsInstall()">查看本机是否安装控件</a><br/>
若只打印《表单一》,看一下<a href="javascript:prn1_preview()">打印预览</a>,可<a href="javascript:prn1_print()">直接打印</a>也可<a href="javascript:prn1_printA()">选择打印机</a>打印。<br/>
<b>以下为打印部分</b><br/><br/><br/><br/>
</div>
<div id="divprint">
<table border="1" width="300" id="tb01" bgcolor="#CCFFCC" style="border: solid 1px black;
border-collapse: collapse">
<tr>
<td width="133" id="mtb001">
<font face="黑体" color="#FF0000" size="3"><u> 《表单一》 </u></font>
</td>
</tr>
</table>
<table border="1" width="300" height="106" cellspacing="0" bgcolor="#CCFFFF" style="border-collapse: collapse;
table-layout: fixed; border: solid 1px black;">
<tr>
<td width="66" height="16" style="border: solid 1px black">
<font color="#0000FF">A</font><font color="#0000FF">等</font>
</td>
<td width="51" height="16" style="border: solid 1px black">
<font color="#0000FF">B</font><font color="#0000FF">等</font>
</td>
<td width="51" height="16" style="border: solid 1px black">
<font color="#0000FF">C</font><font color="#0000FF">等</font>
</td>
</tr>
<tr>
<td width="66" height="16" style="border: solid 1px black">
A<sub>01</sub>
</td>
<td width="80" height="12" style="border: solid 1px black">
中-001
</td>
<td width="51" height="12" style="border: solid 1px black">
C1<sup>x</sup>
</td>
</tr>
<tr>
<td width="66" height="16" style="border: solid 1px black">
A<sub>02</sub>
</td>
<td width="80" height="16" style="border: solid 1px black">
日-002</td>
<td width="51" height="16" style="border: solid 1px black">
<font face='Vernada'>7㎥</font>
</td>
</tr>
<tr>
<td width="66" height="16" style="border: solid 1px black; overflow: hidden">
A<sub>03</sub><nobr>over隐藏后面的:1234567890</nobr>
</td>
<td width="80" height="16" style="border: solid 1px black; overflow: hidden">
韩-003</td>
<td width="51" height="16">
C3<sup>x</sup>
</td>
</tr>
</table>
</div>
</form>
</body>

asp.net调用Lodop实现页面打印或局部打印,可进行打印设置或预览

上一篇:精美的 ( Android, iPhone, iPad ) 手机界面设计素材和线框图设计工具


下一篇:在Win7 64位旗舰版下,利用Vs2008编译64位的Qt 4.8.2