ZaiZai 1 year ago
parent
commit
50f9b5d4a2
1 changed files with 11 additions and 3 deletions
  1. 11 3
      src/plugins/HcPdfSign.js

+ 11 - 3
src/plugins/HcPdfSign.js

@@ -149,9 +149,17 @@ export default class HcPdfSign {
     //设置签章图片
     static async signImage(url) {
         const res = await this.getImageSize(url)
-        const scaleFactor = 100 / res.height
-        const newWidth = res.width * scaleFactor
-        this.signImgCss = { url: url, width: newWidth, height: 100 }
+        if (res.width === res.height) {
+            this.signImgCss = { url: url, width: 100, height: 100 }
+        } else if (res.width > res.height) {
+            const scaleFactor = 30 / res.height
+            const newWidth = res.width * scaleFactor
+            this.signImgCss = { url: url, width: newWidth, height: 30 }
+        } else {
+            const scaleFactor = 100 / res.height
+            const newWidth = res.width * scaleFactor
+            this.signImgCss = { url: url, width: newWidth, height: 100 }
+        }
     }
 
     //获取网络图片的高宽