如何在vue專案中使用lodop列印外掛
阿新 • • 發佈:2018-12-24
https://www.jianshu.com/p/d288963c1a80
先寫了個webdemo
<%-- Created by IntelliJ IDEA. User: Administrator Date: 2018/12/17 Time: 13:49 To change this template use File | Settings | File Templates. --%> <%@ page contentType="text/html;charset=UTF-8" language="java" %> <html> <head> <title>$Title$</title> <%--<script type="text/javascript" src="../res/vankewebstyle/js/jquery-1.9.0.js"></script>--%> <script language="javascript" src="lodop/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 pluginspage="install_lodop.exe"></embed> </object> <script type="text/javascript"> var LODOP; //宣告為全域性變數 function printPreview(){ //建立小票列印頁 CreatePrintPage(); //列印預覽 LODOP.PREVIEW(); } function printOrder() { //建立小票列印頁 CreatePrintPage(); //開始列印 LODOP.PRINT(); }; function CreatePrintPage() { var LODOP=getLodop(); LODOP.PRINT_INIT("test"); LODOP.SET_PRINT_PAGESIZE (1,'209mm','196mm',2);//設定紙張大小 LODOP.SET_PRINT_MODE("PRINT_PAGE_PERCENT","Auto-Width");//設定頁面縮放 LODOP.ADD_PRINT_HTM(25,25,"100%","100%",document.getElementById("textarea01").value);//設定頁面填充內容 //LODOP.PRINT(); LODOP.PREVIEW(); } </script> <body> <embed id="LODOP_EM" type="application/x-print-lodop" width=0 height=0 pluginspage="../res/lodop/install_lodop32.exe"></embed> <textarea rows="15" cols="80" style="display: none;" id="textarea01"> <h2> 青島港國際物流有限公司</h2> <h3> 代理費用支出審批單 </h3> <p> <strong> NO.1544670046087</strong></p> <h3> 申請日期:2018-03-14</h3> <table border="1" cellspacing="0" style="width:698.8500pt"> <tbody> <tr> <td colspan="2" style="height:24.9500pt; vertical-align:top; width:141.8000pt"> <p>付款方式: </p> </td> <td colspan="5" style="height:24.9500pt; vertical-align:top; width:324.0500pt"> <p>支票 [√] 網付 [ ] 現金 [ ] 其他 [ ] </p> </td> <td colspan="4" style="height:24.9500pt; vertical-align:top; width:233.0000pt"> <p>申請人: </p> </td> </tr> <tr> <td colspan="2" style="height:25.5500pt; vertical-align:top; width:141.8000pt"> <p>收款單位: </p> </td> <td colspan="5" style="height:25.5500pt; vertical-align:top; width:324.0500pt"> <p>青島尚世通報關公司</p> </td> <td colspan="4" style="height:25.5500pt; vertical-align:top; width:233.0000pt"> <p>申請部門:礦石 </p> </td> </tr> <tr> <td colspan="2" style="height:24.9500pt; vertical-align:top; width:141.8000pt"> <p>開戶行: </p> </td> <td colspan="5" style="height:24.9500pt; vertical-align:top; width:324.0500pt"> <p>青島銀行崇明島支行 </p> </td> <td colspan="4" style="height:24.9500pt; vertical-align:top; width:233.0000pt"> <p>結算稽核: </p> </td> </tr> <tr> <td colspan="2" style="height:24.9500pt; vertical-align:top; width:141.8000pt"> <p>賬號 </p> </td> <td colspan="5" style="height:24.9500pt; vertical-align:top; width:324.0500pt"> <p>6226661584247</p> </td> <td colspan="4" style="height:24.9500pt; vertical-align:top; width:233.0000pt"> <p> </p> </td> </tr> <tr> <td style="height:33.4000pt; vertical-align:top; width:84.9500pt"> <p>客戶名稱 </p> </td> <td style="height:33.4000pt; vertical-align:top; width:56.8500pt"> <p>貨種 </p> </td> <td style="height:33.4000pt; vertical-align:top; width:56.8000pt"> <p>船名 </p> </td> <td style="height:33.4000pt; vertical-align:top; width:71.0500pt"> <p>航次 </p> </td> <td style="height:33.4000pt; vertical-align:top; width:78.1000pt"> <p>提單號 </p> </td> <td style="height:33.4000pt; vertical-align:top; width:99.4500pt"> <p>箱型\箱量 </p> </td> <td colspan="2" style="height:33.4000pt; vertical-align:top; width:92.3000pt"> <p>費用專案 </p> </td> <td style="height:33.4000pt; vertical-align:top; width:81.6500pt"> <p>付款金額 </p> </td> <td colspan="2" style="height:33.4000pt; vertical-align:top; width:77.7000pt"> <p>備註 </p> </td> </tr> <tr> <td style="height:24.9500pt; vertical-align:top; width:84.9500pt"> <p> </p> </td> <td style="height:24.9500pt; vertical-align:top; width:56.8500pt"> <p> </p> </td> <td style="height:24.9500pt; vertical-align:top; width:56.8000pt"> <p> </p> </td> <td style="height:24.9500pt; vertical-align:top; width:71.0500pt"> <p> </p> </td> <td style="height:24.9500pt; vertical-align:top; width:78.1000pt"> <p>附明細 </p> </td> <td style="height:24.9500pt; vertical-align:top; width:99.4500pt"> <p> </p> </td> <td colspan="2" style="height:24.9500pt; vertical-align:top; width:92.3000pt"> <p>單證費 </p> </td> <td style="height:24.9500pt; vertical-align:top; width:81.6500pt"> <p>50.00</p> </td> <td colspan="2" style="height:24.9500pt; vertical-align:top; width:77.7000pt"> <p> </p> </td> </tr> <tr> <td style="height:12.7500pt; vertical-align:top; width:84.9500pt"> <p>合計(¥/$)</p> </td> <td style="height:12.7500pt; vertical-align:top; width:56.8500pt"> <p> </p> </td> <td style="height:12.7500pt; vertical-align:top; width:56.8000pt"> <p> </p> </td> <td style="height:12.7500pt; vertical-align:top; width:71.0500pt"> <p> </p> </td> <td style="height:12.7500pt; vertical-align:top; width:78.1000pt"> <p> </p> </td> <td colspan="3" style="height:12.7500pt; vertical-align:top; width:191.7500pt"> <p> </p> </td> <td colspan="2" style="height:12.7500pt; vertical-align:top; width:82.5500pt"> <p>50.00</p> </td> <td style="height:12.7500pt; vertical-align:top; width:76.8000pt"> <p> </p> </td> </tr> <tr> <td colspan="2" style="height:24.9500pt; vertical-align:top; width:141.8000pt"> <p>大寫 ( 人民幣 / 美金 )</p> </td> <td colspan="9" style="height:24.9500pt; vertical-align:top; width:557.0500pt"> <p>伍拾元整</p> </td> </tr> </tbody> </table> <p>總經理: 財務部經理: 部門經理: </p> <p> </p> <h2> 代理費用支出審批單明細</h2> <p> <strong> NO.1544670046087</strong></p> <p> </p> <table border="1" cellspacing="0" style="width:429.3500pt"> <tbody> <tr> <td style="height:15.4500pt; vertical-align:top; width:45.4500pt"> <p>客戶名稱 </p> </td> <td style="height:15.4500pt; vertical-align:top; width:42.9000pt"> <p>貨種 </p> </td> <td style="height:15.4500pt; vertical-align:top; width:42.9000pt"> <p>船名 </p> </td> <td style="height:15.4500pt; vertical-align:top; width:45.3000pt"> <p>航次 </p> </td> <td style="height:15.4500pt; vertical-align:top; width:74.7000pt"> <p>提單號 </p> </td> <td style="height:15.4500pt; vertical-align:top; width:45.7500pt"> <p>箱型/箱量 </p> </td> <td style="height:15.4500pt; vertical-align:top; width:42.9000pt"> <p>費用專案 </p> </td> <td style="height:15.4500pt; vertical-align:top; width:46.4000pt"> <p>付款金額 </p> </td> <td style="height:15.4500pt; vertical-align:top; width:42.9000pt"> <p>備註 </p> </td> </tr> <tr> <td style="height:16.2000pt; vertical-align:top; width:45.4500pt"> <p>青島光輝通達物流倉儲公司 </p> </td> <td style="height:16.2000pt; vertical-align:top; width:42.9000pt"> <p>錳礦 </p> </td> <td style="height:16.2000pt; vertical-align:top; width:42.9000pt"> <p>asd </p> </td> <td style="height:16.2000pt; vertical-align:top; width:45.3000pt"> <p>123</p> </td> <td style="height:16.2000pt; vertical-align:top; width:74.7000pt"> <p>SHSGSSGS</p> </td> <td style="height:16.2000pt; vertical-align:top; width:45.7500pt"> <p> </p> </td> <td style="height:16.2000pt; vertical-align:top; width:42.9000pt"> <p>報關費 </p> </td> <td style="height:16.2000pt; vertical-align:top; width:46.4000pt"> <p>¥50.0</p> </td> <td style="height:16.2000pt; vertical-align:top; width:42.9000pt"> <p> </p> </td> </tr> <tr> <td style="height:15.4500pt; vertical-align:top; width:45.4500pt"> <p>合計(¥/$)</p> </td> <td colspan="7" style="height:15.4500pt; vertical-align:top; width:340.8500pt"> <p>¥50.00</p> </td> <td style="height:15.4500pt; vertical-align:top; width:42.9000pt"> <p> </p> </td> </tr> <tr> <td colspan="2" style="height:15.4500pt; vertical-align:top; width:88.3500pt"> <p>大寫(人民幣/美金)</p> </td> <td colspan="7" style="height:15.4500pt; vertical-align:top; width:340.8500pt"> <p>伍拾元整</p> </td> </tr> </tbody> </table> <p> 申請人:徐洋洋 </p> <p> 申請日期:2018-03-14</p> <p> </p> </textarea> <input type="button" value="列印預覽" onclick="printPreview()" /> <!-- 控制列印按鈕,自動列印可以直接執行printOrder--> <input type="button" value="直接列印" onclick="printOrder()" /> </body> </html>
生成的word的html還未進行頁面調整,而且還有一些變形,預覽效果顯示真的很差...就先這樣吧。