LODOP的一次使用后的总结
一、lodop打印预览效果图
LODOP.PRINT_SETUP();打印维护效果图
LODOP.PREVIEW();打印预览图
二、写在前面
最近项目用到了LODOP的套打,主要用到两个地方,一是物流的面单(即套打在EMS等各种物流快递单),另一个是把数据画成表格来打印出库单。物流面单比较简单,网上有各种例子还是比较方便的。主要说说通过该工具画表格的用法,当然通过ADD_PRINT_TABLE 这种超文本格式(即通过写好表格的html来实现)的也可以琢磨琢磨。
三、lodop的demo
<html>
<body>
<object id="LODOP" classid="clsid:2105C259-1E0C-4534-8141-A753534CB4CA" width=0 height=0></object>
<script language="javascript" src="LodopFuncs.js"></script>
<script language="javascript" type="text/javascript">
function CreatePrintPage() { var whichOne='jx';
var num=2;
var fenyeSize=0; var printNum;//序号
LODOP.PRINT_INITA(0,0,1800,1460,"套打EMS的模板");
if(whichOne=="bz"||whichOne=="hn"){
LODOP.SET_PRINT_PAGESIZE(0,0,0,"A4");
fenyeSize=1070;
}else if(whichOne=="jx"){
LODOP.SET_PRINT_PAGESIZE(0,'210mm','140mm',"A4");//一开始用的是像素,后来都改成用mm为单位
fenyeSize=140;
}if(whichOne=="zj"){
LODOP.PRINT_INITA(100,11,800,1460,"套打EMS的模板");
fenyeSize=470;
LODOP.SET_PRINT_PAGESIZE(0,1900,1300,"A4");
LODOP.SET_PRINT_MODE("PRINT_PAGE_PERCENT", "Width:80%;Height:80%");
} for(var i=0;i<1;i++){ var lastheght=2;
//上面的信息
if(num!=1){//标准单据有标题, num==1浙江单据没有
LODOP.ADD_PRINT_TEXT("3.39mm","64.4mm","77.55mm","9.6mm","XXXXX平台销售出库单");
LODOP.SET_PRINT_STYLEA(0, "ItemType", 0);
LODOP.SET_PRINT_STYLEA(0, "FontSize", 14);
LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
} var size =19; var extendSize=0;
var table_hegth=(size+1)*25;
var fonsize=4;
//上面的信息
var lsous="11121额鹅鹅鹅"
var shohuor="111"
if(whichOne=="hn"||whichOne=="jx"){ LODOP.ADD_PRINT_TEXT("15.29mm","12.54mm","20.13mm","5.37mm","订单编号:");
LODOP.ADD_PRINT_TEXT("15.29mm","28.18mm","45.56mm","5.37mm","1111111111111111");
LODOP.ADD_PRINT_TEXT("15.29mm","73.37mm","20.13mm","5.37mm","下单日期:");
LODOP.ADD_PRINT_TEXT("15.29mm","88.66mm","20.13mm","5.37mm","2017-0909");
LODOP.ADD_PRINT_TEXT("15.29mm","109.03mm","20.13mm","5.37mm","发货日期:");
LODOP.ADD_PRINT_TEXT("15.29mm","124.65mm","20.13mm","5.37mm","2017-0909");
LODOP.ADD_PRINT_TEXT("6.03mm","154.28mm","27.54mm","14.1mm","1234");
LODOP.SET_PRINT_STYLEA(0, "ItemType", 0);
LODOP.SET_PRINT_STYLEA(0, "FontSize", 32);
LODOP.SET_PRINT_STYLEA(0, "Bold", 1);
LODOP.ADD_PRINT_TEXT("21.11mm","12.54mm","20.13mm","5.37mm","零售商:");
LODOP.ADD_PRINT_TEXT("21.11mm","24.98mm",3+getByteLen(lsous)*1.7+"mm","5.37mm",lsous);
LODOP.ADD_PRINT_TEXT("21.11mm",24.98+3+getByteLen(lsous)*1.7+"mm","20.13mm","5.37mm","收货人:");
LODOP.ADD_PRINT_TEXT("21.11mm",38+3+getByteLen(lsous)*1.7+"mm","20.13mm","5.37mm",shohuor);
LODOP.ADD_PRINT_TEXT("21.11mm",58+3+getByteLen(lsous)*1.7+"mm","20.13mm","5.37mm","联系电话:");
LODOP.ADD_PRINT_TEXT("21.11mm",73+3+getByteLen(lsous)*1.7+"mm","20.13mm","5.37mm","19765663427");
LODOP.ADD_PRINT_TEXT("26.41mm","12.81mm","20.13mm","5.37mm","收货地址:");
LODOP.ADD_PRINT_TEXT("26.41mm","28.68mm","139.99mm","5.37mm","北京天安门广场");
} //标题等
LODOP.ADD_PRINT_TEXT("33.02mm","15.72mm","9.55mm","5.37mm","行号");
LODOP.SET_PRINT_STYLEA(0, "Alignment", 2);
LODOP.ADD_PRINT_TEXT("33.02mm","49.85mm","13.52mm","5.37mm","供货商");
LODOP.ADD_PRINT_TEXT("33.02mm","91.65mm","9.55mm","5.37mm","型号");
LODOP.ADD_PRINT_TEXT("33.02mm","120.5mm","9.55mm","5.37mm","颜色");
LODOP.ADD_PRINT_TEXT("33.02mm","144.57mm","20.13mm","5.37mm","单价(元)");
LODOP.ADD_PRINT_TEXT("33.02mm","162.56mm","9.55mm","5.37mm","数量");
LODOP.ADD_PRINT_TEXT("33.02mm","171.82mm","27.81mm","5.37mm","应付金额(元)"); //表格线
LODOP.ADD_PRINT_LINE("31.31mm","13mm","31.31mm","193.00mm",0,1);// 最上条标题横线
LODOP.ADD_PRINT_LINE("37.31mm","13mm","37.31mm","193.00mm",0,1);// 标题下横线
LODOP.ADD_PRINT_LINE("31.31mm","13mm", "37.11mm", "13mm", 0, 1);// 最左竖线
LODOP.ADD_PRINT_LINE("31.31mm","25mm", "37.11mm", "25mm", 0, 1);// 行号后竖线
LODOP.ADD_PRINT_LINE("31.31mm","83mm", "37.11mm", "83mm", 0, 1);// 供货商后竖线
LODOP.ADD_PRINT_LINE("31.31mm","110mm", "37.11mm", "110mm", 0, 1);// 型号后竖线
LODOP.ADD_PRINT_LINE("31.31mm","140mm", "37.11mm", "140mm", 0, 1);// 颜色后竖线
LODOP.ADD_PRINT_LINE("31.31mm","160mm", "37.11mm", "160mm", 0, 1);// 单价后竖线
LODOP.ADD_PRINT_LINE("31.31mm","170mm", "37.11mm", "170mm", 0, 1);// 数量后竖线
LODOP.ADD_PRINT_LINE("31.31mm","193mm", "37.11mm", "193mm", 0, 1);// 最右竖线 //动态列表信息
var trheight=37.31;//用于每个竖线距离上面的固定长度
var thHeight=37.98;//用于每行商品距离上面的固定长度
var newHeight=0;//用于动态增加一行的长度
var lastSize=0;//分页前的那个下标
var allProductNumber=0;
for(var k=0;k<size;k++){
var aaa="12345678901234567";
var bbb="12345678901";
var ccc="1234567";
newHeight=(k-lastSize)*5.37+extendSize*fonsize;
var SizeTmpt=parseInt(getByteLen(aaa)/35); if(parseInt(getByteLen(bbb)/16)>SizeTmpt){
SizeTmpt=parseInt(getByteLen(bbb)/16);
} if(parseInt(getByteLen(ccc)/17)>SizeTmpt){
SizeTmpt=parseInt(getByteLen(ccc)/17);
}
LODOP.ADD_PRINT_TEXT(thHeight+newHeight+"mm","15.72mm","9.55mm","5.37mm",k+1);
LODOP.SET_PRINT_STYLEA(0, "Alignment", 2);
LODOP.ADD_PRINT_TEXT(thHeight+newHeight+"mm","25mm","58mm",5.3+SizeTmpt*fonsize+"mm",aaa);
LODOP.SET_PRINT_STYLEA(0, "Alignment", 2);
LODOP.ADD_PRINT_TEXT(thHeight+newHeight+"mm","83mm","27mm",5.3+SizeTmpt*fonsize+"mm",bbb);
LODOP.SET_PRINT_STYLEA(0, "Alignment", 2);
LODOP.ADD_PRINT_TEXT(thHeight+newHeight+"mm","110mm","30mm",5.3+SizeTmpt*fonsize+"mm",ccc);
LODOP.SET_PRINT_STYLEA(0, "Alignment", 2);
LODOP.ADD_PRINT_TEXT(thHeight+newHeight+"mm","140mm","20mm","5.37mm",'1234');
LODOP.SET_PRINT_STYLEA(0, "Alignment", 2);
LODOP.ADD_PRINT_TEXT(thHeight+newHeight+"mm","160mm","10mm","5.37mm",'2333');
LODOP.SET_PRINT_STYLEA(0, "Alignment", 2);
LODOP.ADD_PRINT_TEXT(thHeight+newHeight+"mm","170mm","23mm","5.37mm",'2323');
LODOP.SET_PRINT_STYLEA(0, "Alignment", 2); extendSize+=SizeTmpt;
newHeight=(k-lastSize)*5.37+extendSize*fonsize;
if(k==lastSize+1&&k!=1){
LODOP.ADD_PRINT_LINE(trheight+newHeight-SizeTmpt*fonsize+"mm","13mm",trheight+newHeight-SizeTmpt*fonsize+"mm","193mm",0,1);//每条数据后加一横线
}
LODOP.ADD_PRINT_LINE(trheight+newHeight-SizeTmpt*fonsize+"mm","13mm",trheight+newHeight+5.37+"mm","13mm",0,1);//最左竖线
LODOP.ADD_PRINT_LINE(trheight+newHeight-SizeTmpt*fonsize+"mm","25mm",trheight+newHeight+5.37+"mm","25mm",0,1);//行号后竖线
LODOP.ADD_PRINT_LINE(trheight+newHeight-SizeTmpt*fonsize+"mm","83mm",trheight+newHeight+5.37+"mm","83mm",0,1);//供货商后竖线
LODOP.ADD_PRINT_LINE(trheight+newHeight-SizeTmpt*fonsize+"mm","110mm",trheight+newHeight+5.37+"mm",'110mm',0,1);//型号后竖线
LODOP.ADD_PRINT_LINE(trheight+newHeight-SizeTmpt*fonsize+"mm","140mm",trheight+newHeight+5.37+"mm","140mm",0,1);//颜色后竖线
LODOP.ADD_PRINT_LINE(trheight+newHeight-SizeTmpt*fonsize+"mm","160mm",trheight+newHeight+5.37+"mm","160mm",0,1);//单价后竖线
LODOP.ADD_PRINT_LINE(trheight+newHeight-SizeTmpt*fonsize+"mm","170mm",trheight+newHeight+5.37+"mm","170mm",0,1);//数量后竖线
LODOP.ADD_PRINT_LINE(trheight+newHeight-SizeTmpt*fonsize+"mm","193mm",trheight+newHeight+5.37+"mm","193mm",0,1);//最右竖线 LODOP.ADD_PRINT_LINE(trheight+newHeight+5.57+"mm","13mm",trheight+newHeight+5.57+"mm","193mm",0,1);//每条数据后加一横线 if((trheight+newHeight+5.57)%fenyeSize<=fenyeSize&&(trheight+5.57+newHeight)%fenyeSize>=(fenyeSize-15)){ LODOP.NewPage();
thHeight=0.67;
lastSize=k;
trheight=0;
extendSize=0; } } table_hegth=trheight+newHeight+5.57; if(whichOne=="hn"||whichOne=="jx"){
lastheght+=9.4;
LODOP.ADD_PRINT_TEXT(1+table_hegth+"mm","91.65mm","9.55mm","5.37mm","合计");
LODOP.SET_PRINT_STYLEA(0, "Alignment", 2);
LODOP.ADD_PRINT_TEXT(1+table_hegth+"mm","160mm","10mm","5.37mm",'3333');
LODOP.SET_PRINT_STYLEA(0, "Alignment", 2);
LODOP.ADD_PRINT_TEXT(1+table_hegth+"mm","170mm","23mm","5.37mm",'999999');
LODOP.SET_PRINT_STYLEA(0, "Alignment", 2);
LODOP.ADD_PRINT_LINE(4.7+table_hegth+"mm","13mm",4.7+table_hegth+"mm","193mm",0,1);//备注上横线
LODOP.ADD_PRINT_LINE(9.4+table_hegth+"mm","13mm",9.4+table_hegth+"mm","193mm",0,1);//最后一横线
LODOP.ADD_PRINT_LINE(table_hegth+"mm", "13mm", table_hegth+9.4+"mm", "13mm", 0, 1);// 最左竖线
LODOP.ADD_PRINT_LINE(table_hegth+"mm", "160mm", 4.7+table_hegth+"mm", "160mm", 0, 1);// 单价后竖线
LODOP.ADD_PRINT_LINE(table_hegth+"mm", "170mm", 4.7+table_hegth+"mm", "170mm", 0, 1);// 数量后竖线
LODOP.ADD_PRINT_LINE(table_hegth+"mm", "193mm", table_hegth+9.4+"mm", "193mm", 0, 1);// 最右竖线 if((trheight+9.4+newHeight)%fenyeSize<=fenyeSize&&(trheight+newHeight+9.4)%fenyeSize>=(fenyeSize-6)){
LODOP.NewPage();
lastheght=0;
table_hegth=0; }
} // 最下显示订单信息 var moneyWeight=0;
LODOP.ADD_PRINT_TEXT(lastheght+table_hegth+"mm","12.54mm","27.81mm","5.37mm","订单总金额:");
LODOP.ADD_PRINT_TEXT(lastheght+table_hegth+"mm","30mm","27.81mm","5.37mm",'555666'+"元");
moneyWeight+=getByteLen('555666')*1.7+4;
LODOP.ADD_PRINT_TEXT(lastheght+table_hegth+"mm",30+moneyWeight+"mm","3mm","5.37mm","-");
LODOP.ADD_PRINT_TEXT(lastheght+table_hegth+"mm",30+3+moneyWeight+"mm","18.55mm","5.37mm","价保返利:");
LODOP.ADD_PRINT_TEXT(lastheght+table_hegth+"mm",30+17+moneyWeight+"mm","27.81mm","5.37mm","7667元");
moneyWeight+=getByteLen('7667')*1.7+4;
LODOP.ADD_PRINT_TEXT(lastheght+table_hegth+"mm",30+17+moneyWeight+"mm","3mm","5.37mm","-");
LODOP.ADD_PRINT_TEXT(lastheght+table_hegth+"mm",30+20+moneyWeight+"mm","17.81mm","5.37mm","预付款:");
LODOP.ADD_PRINT_TEXT(lastheght+table_hegth+"mm",30+31+moneyWeight+"mm","27.81mm","5.37mm","7887元");
moneyWeight+=getByteLen('7887')*1.7+4;
LODOP.ADD_PRINT_TEXT(lastheght+table_hegth+"mm",30+31+moneyWeight+"mm","3mm","5.37mm","-");
LODOP.ADD_PRINT_TEXT(lastheght+table_hegth+"mm",30+34+moneyWeight+"mm","17.81mm","5.37mm","账期:");
LODOP.ADD_PRINT_TEXT(lastheght+table_hegth+"mm",30+43+moneyWeight+"mm","17.81mm","5.37mm","999元");
moneyWeight+=getByteLen('787')*1.7+4;
LODOP.ADD_PRINT_TEXT(lastheght+table_hegth+"mm",30+43+moneyWeight+"mm","3mm","5.37mm","-");
LODOP.ADD_PRINT_TEXT(lastheght+table_hegth+"mm",30+46+moneyWeight+"mm","17.81mm","5.37mm","优惠券:");
LODOP.ADD_PRINT_TEXT(lastheght+table_hegth+"mm",30+57+moneyWeight+"mm","17.81mm","5.37mm","888元");
moneyWeight+=getByteLen('787')*1.7+4;
LODOP.ADD_PRINT_TEXT(lastheght+table_hegth+"mm",30+57+moneyWeight+"mm","3mm","5.37mm","-");
LODOP.ADD_PRINT_TEXT(lastheght+table_hegth+"mm",30+60+moneyWeight+"mm","17.81mm","5.37mm","预定金:");
LODOP.ADD_PRINT_TEXT(lastheght+table_hegth+"mm",30+71+moneyWeight+"mm","17.81mm","5.37mm","555元");
moneyWeight+=getByteLen('788')*1.7+4;
LODOP.ADD_PRINT_TEXT(lastheght+table_hegth+"mm",30+71+moneyWeight+"mm","3mm","5.37mm","=");
LODOP.ADD_PRINT_TEXT(lastheght+table_hegth+"mm",30+74+moneyWeight+"mm","18.55mm","5.37mm","线上支付:");
LODOP.ADD_PRINT_TEXT(lastheght+table_hegth+"mm",30+88+moneyWeight+"mm","17.81mm","5.37mm","555元"); if(whichOne=="hn"||whichOne=="jx"){
if((lastheght+table_hegth+5)%fenyeSize<=fenyeSize&&(lastheght+table_hegth+5)%fenyeSize>=(fenyeSize-6)){
LODOP.NewPage();
lastheght=0;
table_hegth=0; }
LODOP.ADD_PRINT_TEXT(lastheght+table_hegth+5+"mm","12.54mm","27.81mm","5.37mm","制单人:");
LODOP.ADD_PRINT_TEXT(lastheght+table_hegth+5+"mm","62.54mm","27.81mm","5.37mm","配货员:");
LODOP.ADD_PRINT_TEXT(lastheght+table_hegth+5+"mm","112.54mm","27.81mm","5.37mm","检验员:");
LODOP.ADD_PRINT_TEXT(lastheght+table_hegth+5+"mm","162.54mm","27.81mm","5.37mm","包装员:");
}
LODOP.NewPage();
}
LODOP.PRINT_SETUP(); }; function getByteLen(val) {
var len = 0;
for (var i = 0; i < val.length; i++) {
if (val[i].match(/[^\x00-\xff]/ig) != null) //全角
len += 2;
else
len += 1;
}
return len;
} </script>
进入<a href="javascript:;" onclick="javascript:CreatePrintPage();LODOP.PRINT_DESIGN();">模板设计</a><br><br>
进入<a href="javascript:;" onclick="javascript:CreatePrintPage();">模板的打印预览</a>
</body>
</html>
三、表格设计思路
来源是官网的http://www.c-lodop.com/demolist/PrintSampleA1.html。主要是画线条,每个循环数据都在后面加横线和竖线,里面根据纸张分好页既可。
四、注意事项
1、 LODOP.PRINT_SETUP();打印维护会导致打印的时候左下角有lodop水印,不用就没有,或者注册后就没有了。
2、简单的获取打印次数可以用这个方法。
LODOP.On_Return=function(TaskID,Value){
alert(Value);
};
3、lodop的各种demo官方网站http://www.mtsoftware.cn/LodopDemo.html。
4、附件是lodop技术文档和各种lodop插件以及demo 下载附件
5、碰到几次客户反映和开发效果不一致的原因,是因为插件导致的,具体可参照http://blog.sina.com.cn/s/blog_157ebf1370102wprq.html,不同插件界面不一样,打印的操作也不一样
LODOP的一次使用后的总结的更多相关文章
- Lodop如何设置预览后导出带背景的图,打印不带背景图
Lodop中的ADD_PRINT_SETUP_BKIMG,可以加载上背景图,该背景图在预览的时候可以显示也可以不显示,打印可以打印出来也可以不打印出来.一般套打,都是不打印背景图的,比如一些快递的快递 ...
- Lodop生成文档式模版
Lodop模版有两种方法,一种是传统的JS语句,可以用JS方法里的eval来执行,一种是文档式模版,是特殊格式的base64码,此篇博文介绍文档式模版的生成方法.两种模版都可以存入一下地方进行调用,比 ...
- LODOP安装参数 及静默安装
在cmd命令里里静默安装lodop(c-lodop不能静默安装),本人的安装文件放在D:\lodopdownload\3060\Lodop6.224_Clodop3.060,如下所示: lodop静默 ...
- Lodop打印语句最基本结构介绍(什么是一个任务)
Lodop中最基本的打印过程至少有初始化语句.添内容语句和打印语句三部分组成,例如: LODOP.PRINT_INIT("打印任务名"); //首先一个初始化语句 LODOP.AD ...
- erp前端项目总结
目录 一.项目目录(vue-cli2) 二.开发实践 (一) 权限 (二) 各组件间传递数据 (四) 路由 (七) 组织部门业务员三级联动 (八) 优化性能,手动绑定下拉框数据 (九) 验证 (十) ...
- chrome升级后LODOP打印插件无法使用
今天帮朋友使用LODOP实现一个套打程序时,发现LODOP打印插件在chrome下始终无法使用.分析后发现是自己才升级了chrome,chrome新版默认是禁用npapi的,因此需要手动启用一下,启用 ...
- chrome45以后的版本安装lodop后,仍提示未安装解决
请先查看你chrome浏览器的版本,如果是45版本以前的版本,安装后仍提示 "未安装" 或 "请升级" 请参照本链接解决:http://blog.sina.co ...
- LODOP打印超过后隐藏内容样式
Lodop中的有纯文本和超文本,纯文本本身超过设置的打印项宽度,如果高度足够,就会换行,如果高度设置的很小,不会换行,后面的内容会直接隐藏.除非设置了多页项等,会自动分页.超文本打印项需要用css样式 ...
- LODOP设置判断后执行哪个
LODOP的语句是普通的语句,可以通过JS判断确定要执行哪个,或通过循环循环执行一些语句.如果需要执行某些打印项在哪些条件下不打印,不需要通过代码删除打印项,类似LODOP.SET_PRINT_STY ...
随机推荐
- easyUI tootip组件使用
easyUI tootip组件使用: <!DOCTYPE html> <html lang="en"> <head> <meta char ...
- C# out的使用 函数例题
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...
- 内功心法 -- java.util.ArrayList<E> (3)
写在前面的话:读书破万卷,编码如有神--------------------------------------------------------------------下文主要对java.util ...
- java字节数组格式化为十六进制字符串
/** * 格式化byte * * @param b * @return */ public static String byte2hex(byte[] b) { char[] Digit = { ' ...
- 基于Selenium2与Python自动化测试环境搭建
简介: selenium 是一个web的自动化测试工具,不少学习功能自动化的同学开始首选selenium ,相因为它相比QTP有诸多有点: * 免费,也不用再为破解QTP而大伤脑筋 * 小巧,对于 ...
- delete和delete[]
c++中对new申请的内存的释放方式有delete和delete[两种方式,到底这两者有什么区别呢? 1.我们通常从教科书上看到这样的说明:delete 释放new分配的单个对象指针指向的内存dele ...
- CSS3知识点整理(四)----布局样式及其他
包括CSS3多列布局样式.Flexbox伸缩布局.盒子模型等.重点介绍了Flexbox伸缩布局的各种属性用法. 一.多列布局 为了能在Web页面中方便实现类似报纸.杂志那种多列排版的布局,W3C特意给 ...
- 关于js 构造 onclick 方法中传递Guid参数问题
转义字符单双引号用法:\' 与 \" 例如: $.getJSON("data.json", function(data, status, xhr) { $(" ...
- php安装详解
获取资源: cd /usr/local/src/ wget http://cn2.php.net/distributions/php-5.4.45.tar.bz2 tar jxvf php-5.4.4 ...
- Visual Studio 2017 离线安装方式
Visual Studio, 特别是Visual Studio 2017 通常是一个在线安装程序,如果你在安装过程中失去连接,你可以遇到问题.但是,由于法律原因,微软没有提供完整的可下载的ISO镜像. ...