【个⼈⽤】⼀些常⽤代码,便于拷贝修改粘贴
本⽂⽤于本⼈⽅便使⽤,在测试⼀些功能或例⼦时,需要时可以迅速拷贝代码,然后稍作修改,便于快速测试。
LODOP的⼀些相关语句1,以及常见的页⾯的⼀些链接按钮⽂本框:
<script language="javascript" src="LodopFuncs.js"></script><!--加载LodopFuncs.js,同⼀路径下-->
<script src="localhost:8000/CLodopFuncs.js"></script><!--直接⽤本地的启动的c-lodop-->
<script src='192.168.1.1:8000/CLodopfuncs.js?name=LODOPA'></script><!--页⾯引⽤多个c-lodop时,取名为LODOPA-->
<input type="button" value="点此按钮" onclick="getD()"><!--点击按钮,执⾏某⽅法-->
<input type="text" id="T1" size="15"><!--⼀个id为T1的⽂本框-->
<textarea id="textarea" rows="12" id="S1" cols="107">多⾏⽂本框</textarea><!--多⾏⽂本框,id为S1的-->
<a href="javascript:prn1_preview()">打印预览1</a><br><!--点击链接,执⾏某⽅法-->
<script language="javascript" type="text/javascript">
var LODOP; //声明为全局变量
function prn1_preview() {//进⼊打印设计进⾏设计
LODOP=getLodop();
LODOP.PRINT_INIT("");
LODOP.PRINT_DESIGN();
};
</script>
<script language="javascript" type="text/javascript">
LODOP.PRINT_INIT("");//初始化,不加任务名名
LODOP.PRINT_INITA(0,0,300,500,"");//四个参数的初始化
LODOP.SET_PRINTER_INDEX("Microsoft XPS Document Writer");//指定⾃⼰的xps虚拟打印机
LODOP.SET_PRINTER_INDEX("Brother Color Type3 Class Driver");//指定⾃⼰的该真实打印机驱动
LODOP.SET_PRINT_PAGESIZE(1,300,500,""); //设置⼀个测试⽤的⼩纸张30mm*50mm
LODOP.SET_PRINT_PAGESIZE(1,0,0,"A4"); //设置纸张为A4
LODOP.ADD_PRINT_TEXT(75,6,100,20,"⼀个⽂本");//输出⼀个纯⽂本打印项
LODOP.ADD_PRINT_HTM(0,0,"100%","100%",document.documentElement.innerHTML);//打印整个页⾯
LODOP.ADD_PRINT_HTM(0,0,"100%","100%",ElementById("d1").innerHTML);//⼤打印id为d1的div或其他。
LODOP.NEWPAGE();//分页
html全部居中代码LODOP.PRINT_DESIGN();//打印设计
LODOP.PREVIEW();//打印预览
LODOP.PRINT();//直接打印
LODOP.PRINTA();//直接打印前带选择打印
LODOP.PRINT_SETUP();//打印维护
LODOP.ADD_PRINT_IMAGE(0,0,"100%","100%","<img border='0' src='1.png'/>");//测试某图⽚
LODOP.SET_PRINT_STYLEA(0,"Stretch",2);//按原图⽐例(不变形)缩放模式
LODOP.SET_PRINT_STYLEA(0,"Stretch",1);//图⽚的(可变形)扩展缩放模式
LODOP=ElementById('LODOP2'),ElementById('LODOP_EM2')); //获取内嵌的LODOP
LODOP.SET_SHOW_MODE("DESIGN_IN_BROWSE",1);//在浏览器内嵌打印设计
LODOP.WRITE_FILE_TEXT('UTF-8',ElementById('T2').value,"1aaa");//把内容1aaa以utf-8编码写⼊⽂件
</script>
<!--内嵌显⽰相关-->
<object id="LODOP2" classid="clsid:2105C259-1E0C-4534-8141-A753534CB4CA" width=810 height=407>
<param name="Caption" value="内嵌显⽰区域">
<param name="Border" value="1">
<param name="Color" value="#C0C0C0">
<embed id="LODOP_EM2" TYPE="application/x-print-lodop" width=810 height=407 PLUGINSPAGE="">
</object>
<!--内嵌显⽰相关-->
<!--返回打印设计的代码-->
<a href="javascript:prn1_design()">打印设计</a><br>
<p><textarea rows="12" id="S1" cols="107">返回的打印设计的JS语句</textarea>
<script language="javascript" type="text/javascript">
var LODOP; //声明为全局变量
function prn1_design() {
LODOP=getLodop();
if (LODOP.CVERSION)
CLODOP.On_Return=function(TaskID,Value){ElementById('S1').value=Value;};
};
</script>
<!--返回全部的打印设计代码-->
<!--format格式转换-->
需要转换的值:<input type="text" id="V1" size="23" value="2018-10-23 09:59:17" name="V1">转换后的结果<input type="text" id="V2" size="23" value="" name="V2"> <a href="javascript:prn1_preview()">点击获取结果</a>
<script language="javascript" type="text/javascript">
var LODOP; //声明为全局变量
function prn1_preview() {
LODOP=getLodop();
if (LODOP.CVERSION) CLODOP.On_Return=function(TaskID,Value){ElementById('V2').value=Value;};
var stResult=LODOP.FORMAT("TIME:yyyy-mm",ElementById('V1').value);//转换语句
if (!LODOP.CVERSION) ElementById('V2').value=stResult;
};
</script>
<!--format格式转换-->
c-lodop的⼀些地址:
localhost:8000/ c-lodop的欢迎页⾯
localhost:8000/c_sysmessage c-lodop系统信息和出错信息
[C-Lodop服务所在主机ip]:[C-Lodop端⼝] 云主机欢迎页⾯
[C-Lodop服务所在主机ip或域名]:[C-Lodop端⼝]/c_aoprint AO打印的测试欢迎页⾯
[C-Lodop服务所在主机ip或域名]:[C-Lodop端⼝]/c_aobridge 测试AO端桥下的某打印机
[C-Lodop服务所在主机ip或域名]:[C-Lodop端⼝]/c_mlicense 填写云注册号地址
localhost:8000/c_mlicense 在云主机填写云注册号地址
[C-Lodop服务所在主机ip或域名]:[C-Lodop端⼝]:8000/c_options 云主机的选项
localhost:8000/c_options 云主机的选项
默认admin,密码为空(不限⽤户数的c-lodop注册号可以选择)
LODOP代码2:
<script language="javascript" type="text/javascript">
LODOP.ADD_PRINT_BARCODE(88,32,206,78,"128B","123456789012");//设置条码位置、宽⾼、字体、值
LODOP.SET_PRINT_STYLEA(0,"FontSize",18);//设置上⾯这个条码下⽅的⽂字字体⼤⼩
LODOP.SET_PRINT_STYLEA(0,"Color","#FF0000");//设置当前条码以及条码下⽅字体的颜⾊
LODOP.SET_PRINT_STYLEA(0,"Angle",180);//设置旋转⾓度
LODOP.SET_PRINT_STYLEA(0,"ShowBarText",0);//设置不显⽰条码下⽅的⽂字
LODOP.SET_PRINT_STYLEA(0,"AlignJustify",2);//设置条码下⽅的⽂字相对于条码本⾝居中
LODOP.SET_PRINT_STYLEA(0,"AlignJustify",1);//设置条码下⽅的⽂字相对于条码本⾝居左
LODOP.SET_PRINT_STYLEA(0,"AlignJustify",3);//设置条码下⽅的⽂字相对于条码本⾝居右
LODOP.SET_PRINT_STYLEA(0,"GroundColor","#0080FF");//设置条码的背景⾊
LODOP.SET_PRINT_STYLEA(0,"ShowBarText",0);//条码设置下⽅不显⽰数字
LODOP.SET_PRINT_STYLEA(0,"ItemType",1);//设置上⾯的为页眉页脚,每页固定位置输出
LODOP.SET_PRINT_STYLEA(0,"ItemType",2);//设置上⾯的纯⽂本打印项为页号项
LODOP.SET_PRINT_STYLEA(0,"NumberStartPage",2);//设置从哪⼀页开始显⽰
LODOP.SET_PRINT_STYLEA(0,"StartNumberValue",3);//设置页码从⼏开始显⽰
LODOP.SET_PRINT_STYLEA(0,"NumberStartPage",2);//设置开始显⽰页码的页数
LODOP.SET_PRINT_STYLEA(0,"StartNumberValue",3);//设置页码初始值
LODOP.SET_SHOW_MODE ("HIDE_PBUTTIN_PREVIEW",true);//隐藏预览的打印按钮
LODOP.SET_PRINT_STYLEA(0,"HtmWaitMilSecs",1000)//设置上⼀项延迟超⽂本下载1000毫秒
LODOP.SET_PRINT_STYLEA(0,"Offset2Top",-140);//设置次页向上偏移140
LODOP.SET_PRINT_STYLEA(0,"LetterSpacing",4);//设置当前⽂本的字间距为4
LODOP.SET_PRINT_STYLEA(0,"Alignment",2);//⽂本框⾥内容对于⽂本框居中
LODOP.SET_PRINT_STYLEA(0,"Horient",2);//打印项在纸张中⽔平居中
LODOP.SET_PRINT_STYLEA(0,"Vorient",2);//打印项在纸张中垂直居中。
LODOP.SET_PRINT_STYLEA(0,"AlignJustify",1);//纯⽂本两端对齐
LODOP.SET_PRINT_STYLEA(0,"AlignJustify",2);//设置条码下⽅的⽂字相对于条码本⾝居中
SET_PRINT_MODE("FULL_WIDTH_FOR_OVERFLOW",true); //宽度溢出缩放
SET_PRINT_MODE("FULL_HEIGHT_FOR_OVERFLOW",true);//⾼度溢出缩放
LODOP.SET_PRINT_MODE("RESELECT_PRINTER",true); 允许重选打印机
LODOP.SET_PRINT_MODE("RESELECT_ORIENT",true); 允许重选纸张⽅向
LODOP.SET_PRINT_MODE("RESELECT_PAGESIZE",true); 允许重选纸张
LODOP.SET_PRINT_MODE("RESELECT_COPIES",true); 允许重选份数
LODOP.SET_SHOW_MODE("BKIMG_IN_PREVIEW",1);//预览包含背景图
LODOP.SET_SHOW_MODE("BKIMG_PRINT",1);//打印包含背景图
//同⼀个任务同时发送到不同的打印机打印,
LODOP. SET_PRINT_MODE("NOCLEAR_AFTER_PRINT",true);//设置打印完毕不清理打印信息
LODOP. SET_PRINTER_INDEXA("SG");//设置打印机SG
LODOP.PRINT();//打印
LODOP. SET_PRINTER_INDEXA("HY");//设置打印机HY
LODOP.PRINT();//打印
/
/同⼀个任务同时发送到不同的打印机打印,
</script>
⼀些html1:
<div id="div1"><!--⼀个三⾏三列的table表格,带thead等-->
<table border=1 > <thead>
<tr>
<td>lodop</td>
<td>c-lodop</td>
<td>c-lodop</td>
</tr>
</thead>
<tbody>
<tr>
<td>text</td>
<td>html</td>
<td>html</td>
</tr>
</tBody>
<tfoot>
<tr>
<td>lodop</td>
<td>c-lodop</td>
<td>html</td>
</tr>
</tfoot>
</table>
</div>
<!--⼀个三⾏三列的table表格-->
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论