소스 검색

打印测试

lilei 3 년 전
부모
커밋
b137ab99f8
1개의 변경된 파일7개의 추가작업 그리고 1개의 파일을 삭제
  1. 7 1
      src/libs/JGPrint.js

+ 7 - 1
src/libs/JGPrint.js

@@ -41,7 +41,13 @@ export const JGPrint = function (data, type, printerType) {
     const url = window.URL.createObjectURL(new Blob([data], { type: 'application/pdf' }))
     document.getElementById('print').innerHTML = '<iframe id="printfsqd" name="printfsqd" src="' + url + '" hidden></iframe>'
     if (type == 'preview') { //  预览
-      window.open(url)
+      // window.open(url)
+      const LODOP = getLodop(document.getElementById('LODOP_OB'), document.getElementById('LODOP_EM'))
+      LODOP.SET_SHOW_MODE('HIDE_PAPER_BOARD', 1) //  隐藏底图上有模拟走纸板的条纹线
+      LODOP.SET_PRINT_MODE("POS_BASEON_PAPER",true) // 可使输出以纸张边缘为基点
+      LODOP.ADD_PRINT_PDF(0, 0, '100%', '100%', new Blob([data], { type: 'application/pdf' }))
+      LODOP.SET_PRINT_STYLEA(0, 'PDFScalMode', 1)
+      LODOP.SET_PRINT_PAGESIZE(3, 0, 0, '')
     } else if (type == 'print') { //  打印
       window.frames['printfsqd'].focus()
       window.frames['printfsqd'].print()