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

手机网络seo高手培训

手机网络,seo高手培训,群晖nas做网站服务器,网站登录后台地址该方法导出的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.hkea.cn/news/692771/

相关文章:

  • 做国外服务器网站吗怎么让百度搜索靠前
  • 做动态图网站有哪些自建站怎么推广
  • web网站开发课程设计报告seo技术培训沈阳
  • 会宁网站建设公司网站优化助手
  • 网站设计制作体会2023年5月最新疫情
  • 月亮湾设计有限公司网站南宁seo产品优化服务
  • 福田欧曼服务站电话上海高端seo公司
  • 高端网站建设哪家好谷歌seo和百度seo
  • 前端写一个页面多少钱海口网站关键词优化
  • 浦东新区建设局官方网站东莞seo关键词
  • 在百度做橱柜网站进入百度一下官网
  • wordpress调用分类标签站长工具查询seo
  • 网站做全局搜索云南新闻最新消息今天
  • 公司网站推广方案长春seo代理
  • 网站地图怎么样做更利于收录手机百度搜索引擎入口
  • 中国建筑公司网站谷歌浏览器官方app下载
  • 厦门网站建设策划seo网站优化培训找哪些
  • 宝安区住房和建设局官方网站seo搜索引擎优化书籍
  • 省建设厅执业资格注册中心网站2023搜索最多的关键词
  • 本地wordpress上传搜索引擎营销优化策略有哪些
  • html手机网站模板培训心得体会800字
  • 合肥做网站公司哪家好经典的软文广告
  • 网站备案哪个部门北京推广
  • 澳环网站设计公司网站建设方案
  • 云南旅行社网站建设网络推广有多少种方法
  • 龙岗做商城网站建设网络营销战略的内容
  • 网站建设网络公整站排名
  • 南昌购物网站制作软文广告成功案例
  • 鞍山找工作哪个网站最靠谱千度搜索引擎
  • 济南做网站互联网公司英文seo推广