| | |
| | | v-if="isUpFile"> |
| | | <input type="file" @change="handleFileUpload" accept="application/pdf" ref="fileInput" /> |
| | | </div> |
| | | <p style="color: red;font-size: 12px;margin: 16px 0;" v-if="canvasNumPages > 0">提示:在文件范围内,单击鼠标盖章,双击鼠标已盖好章处可删除当前章</p> |
| | | <div style="color: red;font-size: 12px;margin: 16px 0;" v-if="canvasNumPages > 0">提示:在文件范围内,单击鼠标盖章,双击鼠标已盖好章处可删除当前章</div> |
| | | <canvas ref="pdfCanvas" @click="e => handleCanvasClick(e, index)" style="border: 1px solid #000;" |
| | | @dblclick="e => removeStamp(e, index)" v-for="(item, index) in canvasNumPages" :key="index"></canvas> |
| | | </div> |
| | |
| | | |
| | | <script> |
| | | import jsPDF from "jspdf"; |
| | | import file from '@/utils/file.js' |
| | | export default { |
| | | props: ['isUpFile'], |
| | | data() { |
| | |
| | | } |
| | | const pdf = new jsPDF("p", "mm", "a4"); |
| | | for (let i = 0; i < this.contextList.length; i++) { |
| | | console.log(2222, this.contextList.length, this.$refs.pdfCanvas[i]) |
| | | const imgData = this.$refs.pdfCanvas[i].toDataURL('image/jpeg', 1.0); |
| | | const imgData = this.$refs.pdfCanvas[i].toDataURL('image/jpeg', 0.7); |
| | | const pdfWidth = pdf.internal.pageSize.getWidth(); |
| | | const pdfHeight = (this.$refs.pdfCanvas[i].height * pdfWidth) / this.$refs.pdfCanvas[i].width; |
| | | pdf.addImage(imgData, "JPEG", 0, 0, pdfWidth, pdfHeight); // 将图片添加到 PDF |