演示如何打印PDF文件:
第一步,输入PDF文件来源【文件URL地址 或
本地文件全路径
或文件内容(BASE64码
,打开...
)】
http://localhost:8000/CLodopDemos/PDFDemo.pdf
第二步,选择打印机:
第三步,简单输出
执行如下语句
:
var strURLorContent=document.getElementById('text01').value; var iPrinterIndex=document.getElementById("Select01").value; LODOP=getLodop(); LODOP.PRINT_INIT("测试PDF打印功能"); LODOP.SET_PRINTER_INDEX(iPrinterIndex); LODOP.ADD_PRINT_PDF(0,0,"100%","100%",strURLorContent); LODOP.PREVIEW();
第四步,有时(例如Https方式)需先下载好再打印,可
执行如下语句
:
(注意这步演示需要用https访问本页)
var strURL="https://localhost.lodop.net:8443/CLodopDemos/PDFDemo.pdf"; LODOP=getLodop(); LODOP.PRINT_INIT("测试PDF打印功能"); LODOP.ADD_PRINT_PDF(0,0,"100%","100%",demoDownloadPDF(strURL)); LODOP.PREVIEW();
第五步,更复杂的变形输出
执行如下语句
:
var strURLorContent=document.getElementById('text01').value; var iPrinterIndex=document.getElementById("Select01").value; LODOP=getLodop(); LODOP.PRINT_INIT("测试PDF打印功能"); LODOP.SET_PRINTER_INDEX(iPrinterIndex); LODOP.ADD_PRINT_TEXT(33,73,298,126,"半透明纯文本\r\n旋转重复底印"); LODOP.SET_PRINT_STYLEA(0,"FontSize",16); LODOP.SET_PRINT_STYLEA(0,"Angle",-35); LODOP.SET_PRINT_STYLEA(0,"Alpha",128); //透明度范围值0-255 LODOP.SET_PRINT_STYLEA(0,"Repeat",true); LODOP.ADD_PRINT_PDF(0,0,"100%","100%",strURLorContent); LODOP.SET_PRINT_STYLEA(0,"ScalX",1.5); //水平放大1.5倍 LODOP.SET_PRINT_STYLEA(0,"ScalY",1.2); LODOP.ADD_PRINT_SHAPE(2,31,28,519,546,3,2,"#0080FF"); LODOP.SET_PRINT_STYLEA(0,"CornerRate",0.2); //矩形框的拐角率 LODOP.ADD_PRINT_TEXT(515,89,504,55,"本轮廓字和圆弧框是后加的!"); LODOP.SET_PRINT_STYLEA(0,"OutLine",true); //轮廓字 LODOP.SET_PRINT_STYLEA(0,"FontName","黑体"); LODOP.SET_PRINT_STYLEA(0,"FontSize",25); LODOP.SET_PRINT_STYLEA(0,"FontColor","#0080FF"); LODOP.PREVIEW();
<<回样例目录