45e47118 by renchao@pashanhoo.com

style:证书打印

1 parent 7fed6620
<!--
* @Description:
* @Autor: renchao
* @LastEditTime: 2023-08-10 15:20:52
* @LastEditTime: 2023-08-23 15:36:24
-->
<template>
<div>
......@@ -117,7 +117,7 @@
const image = new Image();
image.onload = () => {
context.drawImage(image, 0, 0);
context.font = '18px 楷体';
context.font = '16px 楷体';
context.fillStyle = '#000000';
context.fillText(this.bdcqz.sjjc ? this.bdcqz.sjjc : '', 60, 56);
context.fillText(this.bdcqz.djnd ? this.bdcqz.djnd : '', 113, 56);
......@@ -131,7 +131,32 @@
context.fillText(this.bdcqz.qlxz ? this.bdcqz.qlxz : '', 138, 303);
context.fillText(this.bdcqz.yt ? this.bdcqz.yt : '', 138, 346);
context.fillText(this.bdcqz.mj ? this.bdcqz.mj : '', 138, 386);
// 使用期限
if (this.bdcqz.syqx && this.bdcqz.syqx.length > 28) {
let lines3 = this.bdcqz.syqx ? this.bdcqz.syqx.split(' ') : [];
lines3.forEach((line, index) => {
const y = 427 + (index * 27); // 每行文本的垂直位置
let currentLine = '';
let arr = [];
for (let word of line) {
const testLine = currentLine + word;
const lineWidth = context.measureText(testLine).width;
if (lineWidth <= 315) {
currentLine = testLine;
} else {
arr.push(currentLine);
currentLine = word;
}
}
arr.push(currentLine);
arr.forEach((line, index) => {
context.fillText(line, 138, y + (index * 20)); // 调整行高
})
})
} else {
context.fillText(this.bdcqz.syqx ? this.bdcqz.syqx : '', 138, 429);
}
// qlqtzk
const maxWidth = 280; // 最大宽度限制
let lines = this.bdcqz.qlqtzk ? this.bdcqz.qlqtzk.split('\n') : [];
......@@ -155,7 +180,7 @@
})
})
let lines1 = this.bdcqz.fj ? this.bdcqz.fj.split(' ') : [];
let lines1 = this.bdcqz.fj ? this.bdcqz.fj.split('\n') : [];
lines1.forEach((line, index) => {
const y = 100 + (index * 37); // 每行文本的垂直位置
let currentLine = '';
......