js 实现 选择照片转换为pdf文件
本文耗时0.5个工作日,终于解决了,vue 图片转pdf 时,图片被分割成多个页面的问题,只能生产一张,图片重叠等多个问题,
本来时给同事做的一个小工具,刚开始直接粘贴网上别人的代码,发现有问题,于是开始研究代码,经过多次尝试,终于完美解决。(-_-)
<template>
<div style="text-align: center">
<h1>图片转pdf</h1>
<div>
<input style="display: none" id="choice" ref="hiddenfile" accept="image/*" class="hiddenInput" multiple type="file" @change="handleFile"/>
<el-button @click="choice">选择图片</el-button>
<el-button @click="start">开始转换</el-button>
<div id="pdfDom" style="margin:auto;width: 700px;margin-top: 20px">
<div v-for="(item,i) in selFiles">
<img width="100%" :id="'fg'+item.id" :src="item.fileimg" alt=""/>
</div>
</div>
</div>
</div>
</template>
<script>
import {jsPDF} from 'jspdf';
export default {
name: "pdf",
components: {},
data() {
retu