|
@@ -24,8 +24,10 @@ export default class HcPdfSign {
|
|
* @param {Function} options.change 回调函数
|
|
* @param {Function} options.change 回调函数
|
|
* @param {Function} options.load 加载完成回调函数
|
|
* @param {Function} options.load 加载完成回调函数
|
|
* @param {boolean} options.isShowYinzhang 是否显示印章
|
|
* @param {boolean} options.isShowYinzhang 是否显示印章
|
|
|
|
+ * @param {number} options.width 签章图片的宽度
|
|
|
|
+ * @param {number} options.height 签章图片的高度
|
|
*/
|
|
*/
|
|
- static createPdf({ ele, url, img, change, load, isShowYinzhang }) {
|
|
|
|
|
|
+ static createPdf({ ele, url, img, change, load, isShowYinzhang, width, height }) {
|
|
this.initVarNull()
|
|
this.initVarNull()
|
|
const dom = this.getDomElement(ele)
|
|
const dom = this.getDomElement(ele)
|
|
if (!dom) return false
|
|
if (!dom) return false
|
|
@@ -41,7 +43,7 @@ export default class HcPdfSign {
|
|
console.warn('请传入签章图片')
|
|
console.warn('请传入签章图片')
|
|
return false
|
|
return false
|
|
}
|
|
}
|
|
- this.signImage(img)
|
|
|
|
|
|
+ this.signImage(img, width, height)
|
|
|
|
|
|
if (!isNullES(change)) {
|
|
if (!isNullES(change)) {
|
|
this.addEventFunc(change)
|
|
this.addEventFunc(change)
|
|
@@ -162,19 +164,23 @@ export default class HcPdfSign {
|
|
}
|
|
}
|
|
|
|
|
|
// 设置签章图片
|
|
// 设置签章图片
|
|
- static async signImage(url) {
|
|
|
|
- const res = await this.getImageSize(url)
|
|
|
|
- if (res.width === res.height) {
|
|
|
|
- this.signImgCss = { url: url, width: 170, height: 170 }
|
|
|
|
- } 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 = 170 / res.height
|
|
|
|
- const newWidth = res.width * scaleFactor
|
|
|
|
- this.signImgCss = { url: url, width: newWidth, height: 170 }
|
|
|
|
- }
|
|
|
|
|
|
+ static async signImage(url, width, height) {
|
|
|
|
+ // const res = await this.getImageSize(url)
|
|
|
|
+ // if (res.width === res.height) {
|
|
|
|
+ // this.signImgCss = { url: url, width: 170, height: 170 }
|
|
|
|
+ // } 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 = 170 / res.height
|
|
|
|
+ // const newWidth = res.width * scaleFactor
|
|
|
|
+ // this.signImgCss = { url: url, width: newWidth, height: 170 }
|
|
|
|
+ // }
|
|
|
|
+ this.signImgCss = { url: url, width: width, height: height }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
// 获取网络图片的高宽
|
|
// 获取网络图片的高宽
|
|
@@ -517,6 +523,8 @@ export default class HcPdfSign {
|
|
|
|
|
|
// 创建签名图片元素
|
|
// 创建签名图片元素
|
|
static createSignImgElement(item) {
|
|
static createSignImgElement(item) {
|
|
|
|
+ console.log(item, 'createSignImgElement')
|
|
|
|
+
|
|
const signImg = document.createElement('img')
|
|
const signImg = document.createElement('img')
|
|
signImg.setAttribute('id', item.id)
|
|
signImg.setAttribute('id', item.id)
|
|
signImg.src = item.url
|
|
signImg.src = item.url
|