tangning 1 dag sedan
förälder
incheckning
943781de8d
1 ändrade filer med 25 tillägg och 5 borttagningar
  1. 25 5
      src/view/case/photos/canvas-photo-editor.js

+ 25 - 5
src/view/case/photos/canvas-photo-editor.js

@@ -1539,7 +1539,15 @@ export class CanvasPhotoEditor {
               ctx.setLineDash([]);
             }
           });
-
+          // 页码
+          ctx.fillStyle = '#666666'
+          ctx.font = `${16}px sans-serif`
+          ctx.textAlign = 'right'
+          ctx.fillText(
+            `第 ${pageIndex + 1 + this.pageCount} 页`,
+            this.pageWidth - (20),
+            this.pageHeight - (20)
+          )
           // ==========================================
           // 🔥 1:1 还原你原 drawGuideLine 标引逻辑
           // ==========================================
@@ -1665,7 +1673,11 @@ exportPagesAsImages(paperType = "a4", name, fileType = 'pdf') {
 
       // 创建画布(和PDF导出尺寸逻辑一致)
       const pageCanvas = document.createElement("canvas");
-      pageCanvas.width = this.pageWidth * DPR * (paperType === "a3" ? 2 : paperType === "a4" ? 1 : 4);
+      let pageWidth = this.pageWidth
+      if(paperType === "four"){
+        pageWidth = pageWidth / (724/840)
+      }
+      pageCanvas.width = pageWidth * DPR * (paperType === "a3" ? 2 : paperType === "a4" ? 1 : 4);
       pageCanvas.height = this.pageHeight * DPR * 1;
       const ctx = pageCanvas.getContext("2d");
       ctx.scale(DPR, DPR);
@@ -1682,7 +1694,7 @@ exportPagesAsImages(paperType = "a4", name, fileType = 'pdf') {
 
         if (paperType === "a3") offsetX = idxInSheet * this.pageWidth;
         if (paperType === "four") {
-          offsetX = idxInSheet * this.pageWidth;
+          offsetX = idxInSheet * pageWidth;
           // offsetY = idxInSheet * this.pageHeight;
         }
 
@@ -1740,7 +1752,15 @@ exportPagesAsImages(paperType = "a4", name, fileType = 'pdf') {
             ctx.setLineDash([]);
           }
         });
-
+          // 页码
+          ctx.fillStyle = '#666666'
+          ctx.font = `${16}px sans-serif`
+          ctx.textAlign = 'right'
+          ctx.fillText(
+            `第 ${pageIndex + 1 + this.pageCount} 页`,
+            this.pageWidth - (20),
+            this.pageHeight - (20)
+          )
           // ==========================================
           // 🔥 1:1 还原你原 drawGuideLine 标引逻辑
           // ==========================================
@@ -1762,7 +1782,7 @@ exportPagesAsImages(paperType = "a4", name, fileType = 'pdf') {
             ctx.lineJoin = 'round';
 
             // 页面全局偏移(核心修正)
-            const pageOffsetX = pageIndex * (this.pageWidth + this.pageMargin);
+            const pageOffsetX = pageIndex * (pageWidth + this.pageMargin);
 
             // 绘制连线
             ctx.beginPath();