Просмотр исходного кода

调整导出PDF签章比预览打印小一号问题

Tony Kang 3 лет назад
Родитель
Сommit
49afbd3f09

+ 14 - 8
app/public/report/js/jpc_output.js

@@ -441,7 +441,7 @@ let JpcCanvasOutput = {
                 img.src = cell.pic;
                 img.crossOrigin = 'anonymous';
                 img.onload = function() {
-                    if (cell.signature_name === JV.SIGNATURE_NAME_DUMMY) {
+                    if (cell.signature_name.indexOf(JV.SIGNATURE_NAME_DUMMY) >= 0) {
                         private_drawImage(cell, control, img, (!!cell.isStamp), [1, 1, 1, 1]);
                     } else {
                         private_drawImage(cell, control, img);
@@ -458,7 +458,12 @@ let JpcCanvasOutput = {
                 }
                 img.crossOrigin = 'anonymous';
                 img.onload = function() {
-                    private_drawImage(cell, control, img, (!!cell.isStamp));
+                    if (cell.signature_name.indexOf(JV.SIGNATURE_NAME_DUMMY) >= 0) {
+                        private_drawImage(cell, control, img, (!!cell.isStamp), [1, 1, 1, 1]);
+                    } else {
+                        private_drawImage(cell, control, img);
+                    }
+                    // private_drawImage(cell, control, img, (!!cell.isStamp));
                 };
                 img.onerror = function() {
                     console.log('cell.path error: ' + cell.path);
@@ -526,10 +531,10 @@ let JpcCanvasOutput = {
         function private_drawImage(cell, control, imageData, orgSize = false, offsetArea) {
             let area = private_getProperSignatureArea(cell, control);
             if (orgSize) {
-                area[0] = cell.area.Left; // Left
-                area[1] = cell.area.Top; // Top
-                area[2] = cell.area.Right; // Right
-                area[3] = cell.area.Bottom; // Bottom
+                area[0] = cell.area.Left + JpcCanvasOutput.offsetX; // Left
+                area[1] = cell.area.Top + JpcCanvasOutput.offsetY; // Top
+                area[2] = cell.area.Right + JpcCanvasOutput.offsetX; // Right
+                area[3] = cell.area.Bottom + JpcCanvasOutput.offsetY; // Bottom
             }
             if (offsetArea) {
                 area[0] = area[0] + offsetArea[0]; // Left
@@ -609,6 +614,7 @@ let JpcCanvasOutput = {
     drawPageBorder: function(rptTpl, canvas, resolution) {
         let me = this;
         let size = me.getReportSizeInPixel(rptTpl, resolution);
+        const shadowPix = 5;
 
         let ctx = canvas.getContext("2d");
         ctx.save();
@@ -624,8 +630,8 @@ let JpcCanvasOutput = {
         ctx.restore();
 
         ctx.fillStyle="black";
-        ctx.fillRect((size[0] + me.offsetX) * me.scaleFactor, (10 + me.offsetY) * me.scaleFactor, 10 * me.scaleFactor, size[1] * me.scaleFactor);
-        ctx.fillRect((10 + me.offsetX) * me.scaleFactor, (size[1] + me.offsetY) * me.scaleFactor, size[0] * me.scaleFactor, 10 * me.scaleFactor);
+        ctx.fillRect((size[0] + me.offsetX) * me.scaleFactor, (shadowPix + me.offsetY) * me.scaleFactor, shadowPix * me.scaleFactor, size[1] * me.scaleFactor);
+        ctx.fillRect((shadowPix + me.offsetX) * me.scaleFactor, (size[1] + me.offsetY) * me.scaleFactor, size[0] * me.scaleFactor, shadowPix * me.scaleFactor);
     },
     highlightConflictArea: function (pageObj, pageIdx) {
         const _chkAndSetConflict = function(orgCells) {

+ 15 - 12
app/public/report/js/rpt_jspdf.js

@@ -2,8 +2,10 @@
  * Created by Tony on 2019/9/10.
  */
 
+// const PDF_SCALE = 0.75;
 const PDF_SCALE = 0.75;
 // const DPI = getScreenDPI();
+const NORMAL_LINE_WEIGHT = 0.5;
 
 let JpcJsPDFHelper = {
     doc: null,
@@ -139,7 +141,7 @@ let JpcJsPDFHelper = {
             } else {
                 control = cell[JV.PROP_CONTROL];
             }
-            private_drawImage(doc, ctx, cell, control, cell.pic, [1, 1, 1, 1]);
+            private_drawImage(doc, ctx, cell, control, cell.pic, (!!cell.isStamp), [1, 1, 1, 1]);
         }
 
         function private_drawSignature(doc, ctx, cell, styles, controls, mergedBand, onlyShowBorder, signatureRelArr) {
@@ -165,7 +167,8 @@ let JpcJsPDFHelper = {
             }
             if (cell.pic) {
                 if (cell.signature_name.indexOf(JV.SIGNATURE_NAME_DUMMY) >= 0) {
-                    private_drawImage(doc, ctx, cell, control, cell.pic, [1, 1, 1, 1]);
+                // if (cell.signature_name.indexOf(JV.SIGNATURE_NAME_DUMMY) >= 0) {
+                    private_drawImage(doc, ctx, cell, control, cell.pic, (!!cell.isStamp), [1, 1, 1, 1]);
                 } else {
                     private_drawImage(doc, ctx, cell, control, cell.pic);
                 }
@@ -229,13 +232,13 @@ let JpcJsPDFHelper = {
             return rst;
         }
 
-        function private_drawImage(doc, ctx, cell, control, imageData, offsetArea) {
+        function private_drawImage(doc, ctx, cell, control, imageData, orgSize = false, offsetArea) {
             let area = private_getProperSignatureArea(cell, control);
-            if (cell.signature_name.indexOf(JV.SIGNATURE_NAME_DUMMY) >= 0) {
-                area[0] = cell[JV.PROP_AREA][JV.PROP_LEFT] + 1 + offsetX; // Left
-                area[1] = cell[JV.PROP_AREA][JV.PROP_TOP] + 1 + offsetX; // Top
-                area[2] = cell[JV.PROP_AREA][JV.PROP_RIGHT] - 1 + offsetX; // Right
-                area[3] = cell[JV.PROP_AREA][JV.PROP_BOTTOM] - 1 + offsetX; // Bottom
+            if (orgSize) {
+                area[0] = cell[JV.PROP_AREA][JV.PROP_LEFT] + offsetX; // Left
+                area[1] = cell[JV.PROP_AREA][JV.PROP_TOP] + offsetX; // Top
+                area[2] = cell[JV.PROP_AREA][JV.PROP_RIGHT] + offsetX; // Right
+                area[3] = cell[JV.PROP_AREA][JV.PROP_BOTTOM] + offsetX; // Bottom
             }
             if (offsetArea) {
                 area[0] = area[0] + offsetArea[0]; // Left
@@ -270,10 +273,10 @@ let JpcJsPDFHelper = {
             }
             if (destStyle[styleBorderDest] && parseFloat(destStyle[styleBorderDest][JV.PROP_LINE_WEIGHT]) !== 0) {
                 doc.setDrawColor(destStyle[styleBorderDest][JV.PROP_COLOR]);
-                if (parseInt(destStyle[styleBorderDest][JV.PROP_LINE_WEIGHT]) === 2) {
-                    doc.setLineWidth(1 * destStyle[styleBorderDest][JV.PROP_LINE_WEIGHT]);
+                if (parseInt(destStyle[styleBorderDest][JV.PROP_LINE_WEIGHT]) >= 2) {
+                    doc.setLineWidth(0.8 * destStyle[styleBorderDest][JV.PROP_LINE_WEIGHT]);
                 } else {
-                    doc.setLineWidth(0.1);
+                    doc.setLineWidth(NORMAL_LINE_WEIGHT);
                 }
                 doc.line((cell[JV.PROP_AREA][startP[0]] + offsetX) * PDF_SCALE, (cell[JV.PROP_AREA][startP[1]] + offsetY) * PDF_SCALE,
                     (cell[JV.PROP_AREA][destP[0]] + offsetX) * PDF_SCALE, (cell[JV.PROP_AREA][destP[1]] + offsetY) * PDF_SCALE);
@@ -497,7 +500,7 @@ let JpcJsPDFHelper = {
                 }
 
                 doc.setDrawColor("BLACK");
-                doc.setLineWidth(0.1);
+                doc.setLineWidth(NORMAL_LINE_WEIGHT);
                 doc.line(startX * PDF_SCALE, startY * PDF_SCALE, endX * PDF_SCALE, endY * PDF_SCALE);
             }
 

+ 23 - 4
app/public/report/js/rpt_print.js

@@ -269,7 +269,11 @@ function buildSignatureCellSvg(cell, styles, controls, fonts, pageMergeBorder, r
         control = controls[cell[JV.PROP_CONTROL]];
     }
     if (cell.pic || cell.path) {
-        buildImage(rst, cell, control, offsetX, offsetY, adjustY, isHtoV, HtoVStr);
+        if (cell.signature_name.indexOf(JV.SIGNATURE_NAME_DUMMY) >= 0) {
+            buildImage(rst, cell, control, offsetX, offsetY, HtoVStr, (!!cell.isStamp), [1,1,1,1]);
+        } else {
+            buildImage(rst, cell, control, offsetX, offsetY, HtoVStr);
+        }
     }
 
     return rst.join("");
@@ -336,7 +340,7 @@ function buildCellSvg(cell, fonts, styles, controls, pageMergeBorder, rptMergeBo
     return rst.join("");
 }
 
-function buildImage(destRst, cell, control, offsetX, offsetY, adjustY, isHtoV, HtoVStr) {
+function buildImage(destRst, cell, control, offsetX, offsetY, HtoVStr, orgSize = false, offsetArea) {
     let href = '';
     if (cell.pic) {
         href = 'href="' + cell.pic +'"';
@@ -344,12 +348,27 @@ function buildImage(destRst, cell, control, offsetX, offsetY, adjustY, isHtoV, H
         href = 'xlink:href="' + cell.path +'"';
     }
     const area = getProperSignatureArea(cell, control, offsetX, offsetY);
+    /*
     if (cell.signature_name.indexOf(JV.SIGNATURE_NAME_DUMMY) >= 0) {
         area[0] = cell[JV.PROP_AREA][JV.PROP_LEFT] + 1 + offsetX; // Left
-        area[1] = cell[JV.PROP_AREA][JV.PROP_TOP] + 1 + offsetX; // Top
+        area[1] = cell[JV.PROP_AREA][JV.PROP_TOP] + 1 + offsetY; // Top
         area[2] = cell[JV.PROP_AREA][JV.PROP_RIGHT] - 1 + offsetX; // Right
-        area[3] = cell[JV.PROP_AREA][JV.PROP_BOTTOM] - 1 + offsetX; // Bottom
+        area[3] = cell[JV.PROP_AREA][JV.PROP_BOTTOM] - 1 + offsetY; // Bottom
+    }
+    /*/
+    if (orgSize) {
+        area[0] = cell[JV.PROP_AREA][JV.PROP_LEFT] + offsetX; // Left
+        area[1] = cell[JV.PROP_AREA][JV.PROP_TOP] + offsetY; // Top
+        area[2] = cell[JV.PROP_AREA][JV.PROP_RIGHT] + offsetX; // Right
+        area[3] = cell[JV.PROP_AREA][JV.PROP_BOTTOM] + offsetY; // Bottom
+    }
+    if (offsetArea) {
+        area[0] = area[0] + offsetArea[0]; // Left
+        area[1] = area[1] + offsetArea[1]; // Top
+        area[2] = area[2] - offsetArea[2]; // Right
+        area[3] = area[3] - offsetArea[3]; // Bottom
     }
+    //*/
     destRst.push('<image x="' + area[0] + '" y="' + area[1] + '" width="' + (area[2] - area[0]) + '" height="' + (area[3] - area[1]) + '" ');
     destRst.push(href + HtoVStr + ' />');
 }