使用LODOP实现循环打印

本文详细介绍了如何使用LODOP插件在动态生成的页面上实现循环打印功能,包括安装插件、引入代码、实现打印操作等步骤,并通过实例展示了打印过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1、首先使用LODOP这个web打印插件,需要进入LODOP官网http://www.lodop.net/demo.html下载install_lodop.exe安装

2、要引入下面这段代码:

<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>

3、实现循环打印,我这个打印是在页面动态生成多个div,每次打印时只打印一个div里面的内容。

<script type="text/javascript">
	var LODOP; // 声明为全局变量
	// 打印操作
	var timer, recCount, rownum;
	function choosePrint() {
		rownum = 0;
		recCount = <%=list.size()%>;
		showPrint(rownum);
		timer = setInterval(printSave, "500");
	}
	function printSave() {
		if (LODOP.PRINTA()) {
			alert(000000);
			if (rownum >= recCount) {
				clearInterval(timer);
			} else {
				showPrint(rownum);
			}
		} else {
			if (rownum >= recCount) {
				clearInterval(timer);
			} else {
				showPrint(rownum);
			}
		}
	}
	function showPrint(id) {
		Design1(id);
		rownum++;
	}

	function Design1(id) {
		CreatePrintPage(id);
		LODOP.PREVIEW();
	};

	function CreatePrintPage(id) {
		LODOP=getLodop(document.getElementById('LODOP_OB'),document.getElementById('LODOP_EM'));
		LODOP.PRINT_INIT("打印控件功能演示_Lodop功能_分页输出二");
        var strHTML="<table border='0' width='100%' >";
        strHTML=strHTML+"<tr><td>";
		strHTML=strHTML+document.getElementById("div"+id).innerHTML;
		strHTML=strHTML+"</td></tr>";
		LODOP.ADD_PRINT_TABLE(88,200,350,1,strHTML);
	};	
</script>

其中 <%=list.size()%>是需要打印数据的行数,即要在页面动态生成几个div。

<body>
	<input type="button" id="btn" value="打印" width="20px;" height="60px;"
		onclick="choosePrint()">
	<form id="printForm" name="printPrint"
		action="/qrcode/qrcodepPrint.action">
		<c:forEach var="qrCodeList" items="${qrCodeList }" varStatus="code">
			<div class="div000" id="div${code.index}">
				<table>
					<tr>
						<td width="50px;">物料${code.index}:</td>
						<td><input style="border: 0px;" type="text" id="wuliao" name="wuliao"
							value="${qrCodeList.wuliao}"></td>
					</tr>
					<tr>
						<td colspan=2><textarea style="resize: none;border: 0px;" cols="35" id="remark" name="remark">${qrCodeList.remark}</textarea>
						</td>
					</tr>
				</table>
				<div>
					<div>
						<table>
							<tr>
								<td>
									<table>
										<tr>
											<td>供应商:</td>
											<td><input style="border: 0px;" type="text" id="suppler" name="suppler"
												value="${qrCodeList.suppler}"></td>
										</tr>
										<tr>
											<td>序号:</td>
											<td><input style="border: 0px;" type="text" id="xuhao" name="xuhao"
												value="${qrCodeList.xuhao}"></td>
											<td></td>
										</tr>
									</table>
								</td>
								<td><img width="79" height="79"
									src="<%=request.getContextPath()%>/qrcodes/${qrCodeList.imagePath}" />
								</td>
							</tr>
						</table>
					</div>
				</div>
			</div>
		</c:forEach>
	</form>
</body>


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

code come

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值