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

重庆网站平台设计关于北京的网页

重庆网站平台,设计关于北京的网页,中国万网ceo,局域网电脑做网站服务器代码如下#xff0c;直接粘贴复制即可#xff0c;代码中 jspdf 是全局引入#xff0c;你可以自己局部引入 别人使用标签的方式来显示 base64#xff0c;但是当页面过长时#xff0c;base64 大小过大会导致页面解析异常#xff0c;显示白屏 import html2canvas from html2…代码如下直接粘贴复制即可代码中 jspdf 是全局引入你可以自己局部引入 别人使用标签的方式来显示 base64但是当页面过长时base64 大小过大会导致页面解析异常显示白屏 import html2canvas from html2canvas;export function printPdf(dom: HTMLElement | null) {// 1 dom 存在if (!dom) return;// 2 生成 canvashtml2canvas(dom, { useCORS: true, allowTaint: true }).then(function (canvas) {// document.body.appendChild(canvas);// return;// 1 canvas 宽高const contentWidth canvas.width;const contentHeight canvas.height;console.log(contentWidth contentHeight, contentWidth, contentHeight);// 2 一页 pdf 显示 html 页面生成的 canvas 高度const pageHeight (contentWidth / 592.28) * 841.89;// 3 未生成 pdf 的 html 页面高度let leftHeight contentHeight;// 4 pdf 页面偏移let position 0;// 5 a4纸的尺寸 [595.28, 841.89]html 页面生成的 canvas 在 pdf 中图片的宽高const imgWidth 595.28;const imgHeight (592.28 / contentWidth) * contentHeight;const img canvas.toDataURL(image/jpeg, 1.0);const pdf new jspdf.jsPDF(, pt, a4);// 有两个高度需要区分一个是html页面的实际高度和生成 pdf 的页面高度(841.89)// 当内容未超过 pdf 一页显示的范围无需分页if (leftHeight pageHeight) {pdf.addImage(img, JPEG, 0, 0, imgWidth, imgHeight);} else {while (leftHeight 0) {console.log(imgWidth, imgHeight, position, leftHeight);pdf.addImage(img, JPEG, 0, position, imgWidth, imgHeight);leftHeight - pageHeight;position - 841.89;// 避免添加空白页if (leftHeight 0) {pdf.addPage();}}}// 6 挂载至页面const blob dataURLtoBlob(pdf.output(datauristring));console.log(blob);const url window.URL.createObjectURL(blob); //获得一个pdf的url对象location.href url;// window.open(url, _blank)//打开一个新窗口// console.log(url);// URL.revokeObjectURL(url) //释放内存// const base64String btoa(pdf.output());// const embed embed typeapplication/pdf srcdata:application/pdf;base64, ${base64String} width100% height100%;// document.documentElement.style.overflow hidden;// document.body.innerHTML embed;}); }
http://www.zqtcl.cn/news/81085/

相关文章:

  • 盖州网站建设请被人做网站
  • 如何做挂qq的网站江苏高效网站制作机构
  • 昆明网站策划网页设计与网站建设题库
  • 制作网站首页psd住建局领导班子成员分工
  • 茶叶网站设计谷歌seo优化中文章
  • 建站之星导出网站广州设计公司排名榜
  • 如何建多语言网站西宁网站建设公司哪家好
  • 网站关键词过多wordpress上传失败
  • 兰州做网站哪家专业腾讯企业邮箱注册入口官网
  • 建设网站后台设计网站建设选题报告
  • 乐清网页设计公司哪家好重庆seo主管
  • 书店网站的建设百度网站描述
  • 郑州外贸网站建站温州做网站找哪家好
  • html制作静态网站模板有没有正规的毕设代做网站
  • 网站专题页面文案设计wordpress redis密码
  • 湖北省职业能力建设处网站wordpress页数显示无限函数
  • 网站建设百度中移电子商务有限公司
  • 网站制作顺序wordpress文章引用格式
  • 一个网站的欢迎页怎样做怎么做网站最便宜
  • 免费网站登录口看完你会感谢我近期发生的新闻
  • 安义南昌网站建设公司电子商务网站建设的实训报告
  • 如何做网站卖连接微信开店小程序怎么弄
  • 食品网站建设网站定制开发枣庄市 网站建设
  • 互联网行业网站模板wordpress缓存清除
  • 如何编辑自己的网站做企业网站备案都需要什么资料
  • 服装商城网站建设直播做ppt的网站有哪些
  • 做哪个网站好游戏开发自学
  • 手把手教你做网站7高端品牌包包排行榜前十名
  • 长春做网站优化哪家好苏州现代建设公司网站
  • 商务网站设计湖南张家界建设局网站