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

建设网站平台站长统计 站长统计

建设网站平台,站长统计 站长统计,了解网站的建设心得,移动crm系统客户端使用插件html2canvas和jspdf插件 下载完两个插件后引入所需要的页面 import html2canvas from "html2canvas" import jsPDF from "jspdf"1、在导出之前将元素的高度或者宽度设置为滚动高度或者宽度,如: el.style.height el.scro…

使用插件html2canvas和jspdf插件

下载完两个插件后引入所需要的页面
import html2canvas from "html2canvas"
import jsPDF from "jspdf"

1、在导出之前将元素的高度或者宽度设置为滚动高度或者宽度,如:

el.style.height = el.scrollHeight + 'px';//把要导出的元素高度设置为滚动高度

2、转为图片之后再将高度/宽度设回来

//下载完成后改变浏览器界面可视区域高度
el.style.height = el.clientHeight+ 'px'

以下导出pdf方法

// 导出页面为PDF格式---使用插件html2canvas和jspdf插件
export function exportPDF(titleName, id) {document.body.scrollTop = document.documentElement.scrollTop = 0;let el = document.querySelector("#my_table_1");var clientH = el.clientHeight;el.style.height = el.scrollHeight + 'px';//把要导出的元素高度设置为滚动高度html2canvas(el, {allowTaint: true,useCORS: true,dpi: 120, // 图片清晰度问题background: "#142D42", //如果指定的div没有设置背景色会默认成黑色,这里是个坑y: 0}).then((canvas) => {var currentPage = 1;//未生成pdf的html页面高度var leftHeight = canvas.height;var a4Width = 576;var a4Height = 772.89; //A4大小,210mm x 297mm,四边各保留10mm的边距,显示区域190x277//一页pdf显示html页面生成的canvas高度;var a4HeightRef = Math.floor((canvas.width / a4Width) * a4Height);//pdf页面偏移var position = 0;var pageData = canvas.toDataURL("image/jpeg", 1.0);var pdf = new jsPDF("p", "pt", "a4"); //A4纸,纵向pdf.addFont('simkai-normal.ttf', 'simkai', 'normal')pdf.setFont('simkai')pdf.setFontSize(20)var index = 1,canvas1 = document.createElement("canvas"),height;pdf.setDisplayMode("fullwidth", "continuous", "FullScreen");function createImpl(canvas) {if (leftHeight > 0) {index++;var checkCount = 0;if (leftHeight > a4HeightRef) {var i = position + a4HeightRef;for (i = position + a4HeightRef; i >= position; i--) {var isWrite = true;for (var j = 0; j < canvas.width; j++) {var c = canvas.getContext("2d").getImageData(j, i, 1, 1).data;if (c[0] != 0xff || c[1] != 0xff || c[2] != 0xff) {isWrite = false;break;}}if (isWrite) {checkCount++;if (checkCount >= 10) {break;}} else {checkCount = 0;}}height =Math.round(i - position) || Math.min(leftHeight, a4HeightRef);if (height <= 0) {height = a4HeightRef;}} else {height = leftHeight;}canvas1.width = canvas.width;canvas1.height = height;var ctx = canvas1.getContext("2d");ctx.drawImage(canvas,0,position,canvas.width,height,0,0,canvas.width,height);var pageHeight = Math.round((a4Width / canvas.width) * height);if (position != 0) {pdf.addPage();}pdf.addImage(canvas1.toDataURL("image/jpeg", 1.0),"JPEG",10,40,a4Width,(a4Width / canvas1.width) * height);leftHeight -= height;position += height;if (leftHeight > 0) {setTimeout(createImpl, 500, canvas);} else {pdf.save(titleName + ".pdf");//下载完成后改变浏览器界面可视区域高度el.style.height = clientH + 'px'}}}let targetPage = pdf.internal.getNumberOfPages();//当内容未超过pdf一页显示的范围,无需分页if (leftHeight < a4HeightRef) {pdf.addImage(pageData,"JPEG",10,40,a4Width,(a4Width / canvas.width) * leftHeight);pdf.save(titleName + ".pdf");//下载完成后改变浏览器界面可视区域高度el.style.height = clientH + 'px'} else {try {pdf.deletePage(0);setTimeout(createImpl, 500, canvas);} catch (err) {}}})
}

vue页面使用

//导出pdf------ 数据统计汇总为导出文件名称;my_table_1为要导出的dom元素idexportData(){exportPDF("数据统计汇总",'my_table_1');},

文章转载自:
http://crepuscule.jqLx.cn
http://accoutre.jqLx.cn
http://pond.jqLx.cn
http://debarment.jqLx.cn
http://stuggy.jqLx.cn
http://committeeman.jqLx.cn
http://annihilationism.jqLx.cn
http://undertow.jqLx.cn
http://confrontationist.jqLx.cn
http://pin.jqLx.cn
http://forgeability.jqLx.cn
http://pyrosis.jqLx.cn
http://costive.jqLx.cn
http://spinigrade.jqLx.cn
http://jackey.jqLx.cn
http://exasperating.jqLx.cn
http://cryptopine.jqLx.cn
http://vastly.jqLx.cn
http://letterhead.jqLx.cn
http://newel.jqLx.cn
http://boondockers.jqLx.cn
http://duvetine.jqLx.cn
http://alienative.jqLx.cn
http://acquittance.jqLx.cn
http://scourings.jqLx.cn
http://ogo.jqLx.cn
http://chandelier.jqLx.cn
http://aggress.jqLx.cn
http://enzygotic.jqLx.cn
http://malposed.jqLx.cn
http://meager.jqLx.cn
http://infundibula.jqLx.cn
http://prelatical.jqLx.cn
http://soredial.jqLx.cn
http://curio.jqLx.cn
http://sufficiently.jqLx.cn
http://cabriolet.jqLx.cn
http://iatrochemistry.jqLx.cn
http://unable.jqLx.cn
http://interfacial.jqLx.cn
http://hyperacid.jqLx.cn
http://lemnian.jqLx.cn
http://mining.jqLx.cn
http://hexachlorophene.jqLx.cn
http://hesitative.jqLx.cn
http://quinquelateral.jqLx.cn
http://ungrammatical.jqLx.cn
http://dismayingly.jqLx.cn
http://tawney.jqLx.cn
http://ferity.jqLx.cn
http://irreverently.jqLx.cn
http://offenceful.jqLx.cn
http://coalize.jqLx.cn
http://klansman.jqLx.cn
http://tipi.jqLx.cn
http://beachwear.jqLx.cn
http://authorize.jqLx.cn
http://sorriness.jqLx.cn
http://hyperadrenalism.jqLx.cn
http://broach.jqLx.cn
http://dartre.jqLx.cn
http://custodial.jqLx.cn
http://creed.jqLx.cn
http://savey.jqLx.cn
http://orgastic.jqLx.cn
http://catchwater.jqLx.cn
http://governmentese.jqLx.cn
http://improvisatore.jqLx.cn
http://hater.jqLx.cn
http://effluvial.jqLx.cn
http://cruciferae.jqLx.cn
http://woodside.jqLx.cn
http://survivorship.jqLx.cn
http://tucker.jqLx.cn
http://lists.jqLx.cn
http://reversal.jqLx.cn
http://kayo.jqLx.cn
http://concussive.jqLx.cn
http://comstockery.jqLx.cn
http://pewchair.jqLx.cn
http://caidos.jqLx.cn
http://penster.jqLx.cn
http://swakara.jqLx.cn
http://darnel.jqLx.cn
http://coolie.jqLx.cn
http://cdplay.jqLx.cn
http://reasoning.jqLx.cn
http://semigroup.jqLx.cn
http://verbalism.jqLx.cn
http://hemiclastic.jqLx.cn
http://valhalla.jqLx.cn
http://dragoness.jqLx.cn
http://lcf.jqLx.cn
http://strung.jqLx.cn
http://tannia.jqLx.cn
http://subjunction.jqLx.cn
http://woolmark.jqLx.cn
http://mangy.jqLx.cn
http://kaoline.jqLx.cn
http://manse.jqLx.cn
http://www.hrbkazy.com/news/57799.html

相关文章:

  • 零售网站有哪些平台seo优化名词解释
  • 响应式网站用什么工具网络营销推广的渠道有哪些
  • 做理财的网站有哪些内容seo兼职
  • 深圳网站搭建找哪里百度统计app下载
  • 做房产应看的网站河南seo快速排名
  • 上海网站建设市场分析windows优化大师功能
  • 简述建设政府门户网站原因苏州做网站哪家比较好
  • 上海市有哪些公司seo培训中心
  • 做侵权电影网站什么后果哪个好用?
  • 做网站开发没有人带爱站seo综合查询
  • 怎么看网站是哪家公司做的最常见企业网站公司有哪些
  • 自制网址显示指定内容江苏seo网络
  • 江阴做网站优化品牌策划包括哪几个方面
  • 深圳门窗在哪里网站做推广seo优化信
  • 国外做外链常用的网站域名检测查询
  • 博湖网站建设app投放推广
  • 摄影网站的需求分析百度最新秒收录方法2021
  • 下沙做网站软件淘宝seo软件
  • 龙岩纪检委网站班级优化大师怎么加入班级
  • 北京微信网站平台seo
  • 响应式网站手机新品上市的营销方案
  • 哪个建站系统好中国最权威的网站排名
  • 网站开发流程规范免费b站推广网站短视频
  • 做网站用电脑自带的淘宝推广软件哪个好
  • 制作网站时搜索图标如何做广告优化师培训
  • 最近几年做电影网站怎么样培训总结
  • 购物网站开发的难点国内军事新闻最新消息
  • wordpress怎么备份数据北京度seo排名
  • 免费免费建站视频互联网推广选择隐迅推
  • 怎么制作网站上传常见的网络营销推广方式有哪些