当前位置: 首页 > news >正文

微信建设网站哪家好网站批量收录

微信建设网站哪家好,网站批量收录,wordpress 权限 插件,杭州营销网站建设公司该方法导出的pdf大小是A4纸的尺寸,如果大于1页需要根据元素高度进行截断的话,页面元素需要加 class ergodic-dom,方法里面会获取ergodic-dom元素,对元素高度和A4高度做比较,如果大于A4高度,会塞一个空白元素…

该方法导出的pdf大小是A4纸的尺寸,如果大于1页需要根据元素高度进行截断的话,页面元素需要加 class ergodic-dom,方法里面会获取ergodic-dom元素,对元素高度和A4高度做比较,如果大于A4高度,会塞一个空白元素,确保每一个元素在换页的时候不会被分割。

import exportPDFMixin from '@/mixins/exportPDFMixin';
mixins: [exportPDFMixin],
 <span v-show="showEdit" class="export textR" @click="exportPDF('pdfDom', '导出的pdf名称')">导出</span>
//exportPDFMixin.js
import html2Canvas from 'html2canvas';
import JsPDF from 'jspdf';
export default {data() {return {showEdit: true}},methods: {exportPDF(elId, title = "pdf") {this.showEdit = false;this.$nextTick(() => {this.downloadPDF(elId, title);})},downloadPDF(elId, title) {html2Canvas(document.querySelector(`#${elId}`), {allowTaint: true,useCORS: true,onclone: (documentclone) => {this.formatNode(documentclone);}}).then((canvas) => {let contentWidth = canvas.widthlet contentHeight = canvas.heightlet pageHeight = contentWidth / 592.28 * 841.89let leftHeight = contentHeightlet position = 0let imgWidth = 595.28let imgHeight = 592.28 / contentWidth * contentHeightlet pageData = canvas.toDataURL('image/jpeg', 1.0)let PDF = new JsPDF('', 'pt', 'a4')if (leftHeight < pageHeight) {PDF.addImage(pageData, 'JPEG', 0, 0, imgWidth, imgHeight)} else {while (leftHeight > 0) {PDF.addImage(pageData, 'JPEG', 0, position, imgWidth, imgHeight)leftHeight -= pageHeightposition -= 841.89if (leftHeight > 0) {PDF.addPage()}}}PDF.save(title + '.pdf');this.showEdit = true;})},formatNode(documentclone) {let pageHeight = documentclone.querySelector("#pdfDom").scrollWidth / 592.28 * 841.89;let lableListID = documentclone.getElementsByClassName('ergodic-dom');for (let i = 0; i < lableListID.length; i++) {let multiple = Math.ceil((lableListID[i].offsetTop + lableListID[i].offsetHeight) / pageHeight)if (this.isSplit(lableListID, i, multiple * pageHeight)) {let divParent = lableListID[i].parentNode // 获取该div的父节点let _H = multiple * pageHeight - (lableListID[i].offsetTop + lableListID[i].offsetHeight)let newNode = this.getFooterElement(_H)let next = lableListID[i].nextSibling // 获取div的下一个兄弟节点// 判断兄弟节点是否存在if (next) {// 存在则将新节点插入到div的下一个兄弟节点之前,即div之后divParent.insertBefore(newNode, next)} else {// 不存在则直接添加到最后,appendChild默认添加到divParent的最后divParent.appendChild(newNode)}}}},getFooterElement (remainingHeight, fillingHeight = 85) {let newNode = document.createElement('div')newNode.style.background = '#fff'newNode.style.width = 'calc(100% + 8px)'newNode.style.marginLeft = '-4px'newNode.style.marginBottom = '0px'newNode.style.height = (remainingHeight + fillingHeight) + 'px' // pdf截断需要一个空白位置return newNode},isSplit (nodes, index, pageHeight) {return nodes[index].offsetTop + nodes[index].offsetHeight < pageHeight && nodes[index + 1] && nodes[index + 1].offsetTop + nodes[index + 1].offsetHeight > pageHeight},}
}
http://www.mmbaike.com/news/43801.html

相关文章:

  • 没有网站怎么做链接视频教程品牌网络seo方案外包
  • 毕业设计网站怎么做足球最新世界排名表
  • 家纺 网站建设 中企动力潍坊网站建设解决方案
  • 招聘网站简历数据分析怎么做新冠病毒最新消息
  • 想要提高网站排名应该怎么做免费网络推广网站
  • wordpress部署文件夹灰色关键词排名优化
  • 事业单位网站建设计划微信引流获客软件
  • 长沙网站制作公司推荐线上营销推广的公司
  • 高端网站建设网页设计百度广告投放价格
  • 博物馆 网站 建设电子商务是干什么的
  • 青岛怎样做网站中国seo
  • 池州网站制作哪家好网站查询站长工具
  • 铁路工程造价信息网重庆网站seo建设哪家好
  • 代做视频的网站好seo优化关键词0
  • 东阿做网站站长网站查询
  • 做翻译的网站关键词权重
  • 个人网站建设哪家好网络舆情分析
  • 2022当下社会热点话题seo整站优化解决方案
  • php如何创建站点谷歌推广新手教程
  • 怎样更换网站cms营销推广的主要方式
  • 花都营销型网站建设sem优化师是做什么的
  • 商城网站建站系统网站建设问一问公司
  • 本地上海集团网站建设北京网站优化对策
  • 无锡专业做网站公司搜索推广渠道
  • 做网站 php asp.net jsp58和百度哪个推广效果好
  • 怎么样百度能搜到自己的网站关键词优化举例
  • 如何做h5 网站荥阳网络推广公司
  • wordpress 下载插件长沙靠谱seo优化价格
  • 网站相关前置许可官网排名优化
  • 网站前端怎么做方法长沙百度推广排名优化