Warning: error_log(/data/www/wwwroot/hmttv.cn/caches/error_log.php): failed to open stream: Permission denied in /data/www/wwwroot/hmttv.cn/phpcms/libs/functions/global.func.php on line 537 Warning: error_log(/data/www/wwwroot/hmttv.cn/caches/error_log.php): failed to open stream: Permission denied in /data/www/wwwroot/hmttv.cn/phpcms/libs/functions/global.func.php on line 537 亚洲精品午夜国产va久久成人,激情视频导航,亚洲国产精品久久久久久

          整合營銷服務商

          電腦端+手機端+微信端=數據同步管理

          免費咨詢熱線:

          一個精悍的Javascript庫,實現Web打印(print.js)

          載地址在github,文末有使用方法

          github地址:https://github.com/crabbly/Print.js/

          官網:https://printjs.crabbly.com/(可能被墻)

          無法訪問可以加企鵝群看離線版:1006429377

          或者訪問:https://www.yuque.com/caiyongjie/snknlo/ga5ef9

          官網截圖

          簡介

          • 原文:

          Print.js was primarily written to help us print PDF files directly within our apps, without leaving the interface, and no use of embeds. For unique situations where there is no need for users to open or download the PDF files, and instead, they just need to print them.

          One scenario where this is useful, for example, is when users request to print reports that are generated on the server side. These reports are sent back as PDF files. There is no need to open these files before printing them. Print.js offers a quick way to print these files within our apps.

          • 谷歌翻譯:

          Print.js主要是為了幫助我們直接在我們的應用程序中打印PDF文件,而無需離開界面,也不使用嵌入。 對于不需要用戶打開或下載PDF文件的獨特情況,相反,他們只需要打印它們。

          例如,當用戶請求打印在服務器端生成的報告時,這種情況很有用。 這些報告以PDF文件形式發回。 打印前無需打開這些文件。 Print.js提供了一種在我們的應用程序中打印這些文件的快捷方式。

          • 注意的地方:

          PDF files must be served from the same domain as your app is hosted under. Print.js uses iframe to load files before printing them, therefore, it is limited by the Same Origin Policy. This helps preventing Cross-site scripting (XSS) attacks.

          必須在托管應用程序的同一域中提供PDF文件。 Print.js在打印文件之前使用iframe加載文件,因此它受同源策略的限制。 這有助于防止跨站點腳本(XSS)攻擊。

          初體驗

          首先在頁面上添加一個按鈕

          • 打印PDF(注意:火狐不支持iframes,可以使用新標簽頁)
          <button type="button" onclick="printJS('docs/printjs.pdf')">
           Print PDF
           </button>
          
          • 打印大文件(可以彈出提示消息)
          <button type="button" onclick="printJS({printable:'docs/xx_large_printjs.pdf', type:'pdf', showModal:true})">
           Print PDF with Message
           </button>
          
          • html打印
           <form method="post" action="#" id="printJS-form">
           ...
           </form>
           <button type="button" onclick="printJS('printJS-form', 'html')">
           Print Form
           </button>
          
          • 打印帶頭部
           <button type="button" onclick="printJS({ printable: 'printJS-form', type: 'html', header: 'PrintJS - Form Element Selection' })">
           Print Form with Header
           </button>
          
          • 打印圖片
          <img src="images/print-01.jpg" />
           printJS('images/print-01-highres.jpg', 'image')
           printJS({printable: 'images/print-01-highres.jpg', type: 'image', header: 'My cool image header'})
          
          • 帶頭
           printJS({
           printable: ['images/print-01-highres.jpg', 'images/print-02-highres.jpg', 'images/print-03-highres.jpg'],
           type: 'image',
           header: 'Multiple Images',
           imageStyle: 'width:50%;margin-bottom:20px;'
           })
          
          • 從JSON數據
           someJSONdata = [
           {
           name: 'John Doe',
           email: 'john@doe.com',
           phone: '111-111-1111'
           },
           {
           name: 'Barry Allen',
           email: 'barry@flash.com',
           phone: '222-222-2222'
           },
           {
           name: 'Cool Dude',
           email: 'cool@dude.com',
           phone: '333-333-3333'
           }
           ]
           <button type="button" onclick="printJS({printable: someJSONdata, properties: ['name', 'email', 'phone'], type: 'json'})">
           Print JSON Data
           </button>
          
          • 自定義CSS
           <button type="button" onclick="printJS({
          	 printable: someJSONdata,
          	 properties: ['name', 'email', 'phone'],
          	 type: 'json',
          	 gridHeaderStyle: 'color: red; border: 2px solid #3971A5;',
          	 gridStyle: 'border: 2px solid #3971A5;'
          	})">
           Print JSON Data
           </button>
          
          • 自定義頭
           <button type="button" onclick="printJS({
          	 printable: someJSONdata,
          	 properties: [
          		{ field: 'name', displayName: 'Full Name'},
          		{ field: 'email', displayName: 'E-mail'},
          		{ field: 'phone', displayName: 'Phone'}
          	 ],
          	 type: 'json'
           })">
           Print with custom table header text
           </button>
          <button type="button" onclick="printJS({
          		printable: someJSONdata,
          		type: 'json',
          		properties: ['name', 'email', 'phone'],
          		header: '<h3 class="custom-h3">My custom header</h3>',
          		style: '.custom-h3 { color: red; }'
          	 })">
          	Print header raw html
          </button>
          

          安裝使用

           npm install print-js --save
          //或
           yarn add print-js
          


          import print from 'print-js'
          


           //cdn,不知道能不能訪問,我這可以訪問
           https://printjs-4de6.kxcdn.com/print.min.js
           https://printjs-4de6.kxcdn.com/print.min.cssye
           <script src="print.js"></script>
          
          • 如果您將使用模態功能,還包括頁面上的Print.css。
           <link rel="stylesheet" type="text/css" href="print.css">
          



          詳細配置:

          兼容性

          .首先引入js插件

          <!--第一個生成二維碼,2,3分別2種打印插件-->

          <script type="text/javascript" src="/Liems/plugins/aweto/jquery.qrcode.min.js"></script>

          <script type="text/javascript" src="/Liems/plugins/aweto/jquery.jqprint-0.3.js">

          </script><script src="/Liems/plugins/aweto/jquery.PrintArea.js"></script>

          2.然后再html中添加二維碼顯示的位置

          <div id="wai" >

          <div id="qrcode"></div>

          <!--startprint-->

          <div id="daying"><img src="" id="image" style="display: none;"/></div>

          <!--endprint-->

          <button id="bu" class='i-form-button' onclick="stamp()" style="display: none;">打印二維碼</button>

          </div>

          3.然后在js中寫入生成二維碼的方法

          jQuery(function(){

          //獲取身份證號碼

          var idCard = $('#EOEMPMST__0__EEM_SFZ_COD').val();

          var jsons=idCard+"|1";

          var zhi=utf16to8(jsons);

          //判斷是否新建

          if(idCard != null && idCard != ''){

          jQuery('#qrcode').qrcode({

          render : "canvas",

          width : 150,

          height : 150,

          text : zhi

          });

          //保存為圖片

          $("canvas").attr("id","erw");

          var canvas = document.getElementById('erw');

          var context = canvas.getContext('2d');

          var image = new Image();

          var strDataURI =canvas.toDataURL("image/png");

          document.getElementById('image').src = strDataURI;

          document.getElementById('bu').setAttribute('style', 'display: block');

          }

          })

          4.qrcode對中文支持不太好,,所以需要轉碼

          //轉碼

          function utf16to8(str) {

          var out, i, len, c;

          out = "";

          len = str.length;

          for(i = 0; i < len; i++) {

          c = str.charCodeAt(i);

          if ((c >= 0x0001) && (c <= 0x007F)) {

          out += str.charAt(i);

          } else if (c > 0x07FF) {

          out += String.fromCharCode(0xE0 | ((c >> 12) & 0x0F));

          out += String.fromCharCode(0x80 | ((c >> 6) & 0x3F));

          out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F));

          } else {

          out += String.fromCharCode(0xC0 | ((c >> 6) & 0x1F));

          out += String.fromCharCode(0x80 | ((c >> 0) & 0x3F));

          }

          }

          return out;

          }

          5.最后進行局部打印

          //局部打印

          function stamp(){

          var bdhtml=window.document.body.innerHTML;//獲取當前頁的html代碼

          var odd=bdhtml;

          var sprnstr="<!--startprint-->";//設置打印開始區域

          var eprnstr="<!--endprint-->";//設置打印結束區域

          var prnhtml=bdhtml.substring(bdhtml.indexOf(sprnstr)+17); //從開始代碼向后取html

          prnhtml=prnhtml.substring(0,prnhtml.indexOf(eprnstr));//從結束代碼向前取html

          window.document.body.innerHTML=prnhtml;

          window.print();

          //第二種打印jQuery('#wai').PrintArea();

          //還原原網頁

          window.document.body.innerHTML=odd;

          document.getElementById('bu').setAttribute('style', 'display: none');

          document.getElementById('image').src="";

          window.location.reload();

          }

          方法中有業務處理,,忽略即可。大體思路如上,歡迎討論

          、測試代碼,保存為【test.html】

          <!DOCTYPE html>
          <html lang="en">
          
          <head>
              <meta charset="UTF-8">
              <meta name="viewport" content="width=device-width, initial-scale=1.0">
              <title>Document</title>
              <script src="write.js"></script>
          </head>
          
          <body>
              <div id="ID1"></div>
          
              <script>
                  writeformat(()=>{
                      writeln(1, 2, 3, 4);
                      writeln(1, [2, 3], 4);
                      writeln({a:1,b:2});
                      writeln(1, [2, 3], [4, { a:1, b: { c:1, d:2 }},{a:1,b:2} ]);
                      writeln();
                  });
          
                  writebr(1, [2, 3], [4, { a:1, b: { c:1, d:2 }},{a:1,b:2} ]);
          
                  document.getElementById("ID1").innerHTML = getWriteHtml(1, [2, 3], [4, { a:1, b: { c:1, d:2 }},{a:1,b:2} ]);
          
                  writeformat(()=>{
                      write(getWriteHtmlPretty(1, [2, 3], [4, { a:1, b: { c:1, d:2 }},{a:1,b:2},5 ],6));
                  });
              </script>
          </body>
          
          </html>

          效果如下:


          2、源碼(保存為 write.js)


          主站蜘蛛池模板: 亚洲综合国产一区二区三区| 国产产一区二区三区久久毛片国语 | 国产一区二区三区电影| 少妇激情av一区二区| 日韩人妻精品无码一区二区三区| 无码AV天堂一区二区三区| 日韩人妻无码一区二区三区99| 亚洲熟妇成人精品一区| 国产成人久久一区二区三区| www.亚洲一区| 久久精品国产一区| 中文字幕无线码一区2020青青| 国产视频一区二区| 中文字幕精品无码一区二区三区| 日韩一区精品视频一区二区| 香蕉久久ac一区二区三区| 精品久久久久一区二区三区| 蜜桃臀无码内射一区二区三区| 在线免费一区二区| 国产午夜精品一区理论片| 亚洲一区在线免费观看| 视频一区视频二区在线观看| 亚洲AV午夜福利精品一区二区| 国产欧美一区二区精品仙草咪| 人妻无码一区二区三区四区| 久久亚洲日韩精品一区二区三区 | 变态调教一区二区三区| 国产精品一区二区久久不卡| 亚洲熟妇AV一区二区三区浪潮| 久久久久女教师免费一区| 午夜AV内射一区二区三区红桃视| 国产日韩高清一区二区三区 | 日韩经典精品无码一区| 无码国产精品一区二区免费16| 国产精品一区二区综合| 69福利视频一区二区| 在线精品国产一区二区三区 | 亚洲一区在线视频观看| 精品视频一区二区三区| 天堂成人一区二区三区| 香蕉免费一区二区三区|