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

公司网站是否做地方分站百度浏览器网址是多少

公司网站是否做地方分站,百度浏览器网址是多少,合肥做淘宝网站建设,通过ip直连打开网站要怎么做准备做的系统中出现了 想导出当前页面的png或者pdf设计数据较多后端做可能比较麻烦 就自己研究了一下 1、安装html2canvas 、jspdf包 npm install --save html2canvas // 可以将dom元素转为一张图片 npm install --save jspdf // 导出为PDF格式 2、vue组件中引用&#x…

准备做的系统中出现了 想导出当前页面的png或者pdf设计数据较多后端做可能比较麻烦 就自己研究了一下

1、安装html2canvas 、jspdf包

npm install --save html2canvas   // 可以将dom元素转为一张图片
npm install --save jspdf   // 导出为PDF格式

2、vue组件中引用,代码如下:

<template><div class="content"><a-button @click="exportPNG" size="small" type="primary">导出PNG</a-button><a-button @click="exportPDF" size="small" type="primary">导出PDF</a-button><div id="main-charts">需要截取的内容区域我想测试导出是否可行</div></div>
</template>

3、导出png

<script lang="ts" setup>// 引入插件import html2canvas from 'html2canvas';import jsPDF from 'jspdf';// 导出pngconst exportPNG = () => {const ele: HTMLElement | null = document.getElementById('main-charts');html2canvas(ele as HTMLElement).then((canvas: any) => {const contentWidth = canvas.width;const contentHeight = canvas.height;const ctx: any = canvas.getContext('2d');// 添加水印ctx.textAlign = 'center';ctx.textBaseline = 'middle';ctx.rotate((25 * Math.PI) / 180);ctx.font = '20px Microsoft Yahei';ctx.fillStyle = 'rgba(184, 184, 184, 0.8)';for (let i = contentWidth * -1; i < contentWidth; i += 240) {for (let j = contentHeight * -1; j < contentHeight; j += 100) {// 填充文字,x 间距, y 间距ctx.fillText('水印名', i, j);}}const imgUrl = canvas.toDataURL('image/png');const tempLink = document.createElement('a'); // 创建一个a标签tempLink.style.display = 'none';tempLink.href = imgUrl;tempLink.setAttribute('download', '文件名'); // 给a标签添加下载属性if (typeof tempLink.download === 'undefined') {tempLink.setAttribute('target', '_blank');}document.body.appendChild(tempLink); // 将a标签添加到body当中tempLink.click(); // 启动下载document.body.removeChild(tempLink); // 下载完毕删除a标签window.URL.revokeObjectURL(imgUrl);})}
</script>

4、导出pdf

<script lang="ts" setup>// 引入插件import html2canvas from 'html2canvas';import jsPDF from 'jspdf';const exportPDF = () => {const ele: HTMLElement | null = document.getElementById('main-charts');html2canvas(ele as HTMLElement, {dpi: 96, // 分辨率scale: 2, // 设置缩放useCORS: true, // 允许canvas画布内 可以跨域请求外部链接图片, 允许跨域请求。,// backgroundColor:'#ffffff',这样背景还是黑的bgcolor: '#ffffff', // 应该这样写logging: false, // 打印日志用的 可以不加默认为false}).then((canvas) => {const contentWidth = canvas.width;const contentHeight = canvas.height;// 一页pdf显示html页面生成的canvas高度;const pageHeight = (contentWidth / 592.28) * 841.89;// 未生成pdf的html页面高度let leftHeight = contentHeight;// 页面偏移let position = 0;// a4纸的尺寸[595.28,841.89],html页面生成的canvas在pdf中图片的宽高const imgWidth = 595.28;const imgHeight = (595.28 / contentWidth) * contentHeight;const ctx: any = canvas.getContext('2d');// 添加水印ctx.textAlign = 'center';ctx.textBaseline = 'middle';ctx.rotate((25 * Math.PI) / 180);ctx.font = '20px Microsoft Yahei';ctx.fillStyle = 'rgba(184, 184, 184, 0.8)';for (let i = contentWidth * -1; i < contentWidth; i += 240) {for (let j = contentHeight * -1; j < contentHeight; j += 100) {// 填充文字,x 间距, y 间距ctx.fillText('水印名', i, j);}}const pageData = canvas.toDataURL('image/jpeg', 1.0);const pdf = new jsPDF('', 'pt', 'a4');if (leftHeight < pageHeight) {// 在pdf.addImage(pageData, 'JPEG', 左,上,宽度,高度)设置在pdf中显示;pdf.addImage(pageData, 'JPEG', 0, 0, imgWidth, imgHeight);} else {// 分页while (leftHeight > 0) {pdf.addImage(pageData,'JPEG',0,position,imgWidth,imgHeight);leftHeight -= pageHeight;position -= 841.89;// 避免添加空白页if (leftHeight > 0) {pdf.addPage();}}}// 可动态生成pdf.save(`文件名.pdf`);});}
</script>

http://www.wooajung.com/news/20888.html

相关文章:

  • 陕西网站开发网络推广公司服务内容
  • 老鹰主机做的网站目前最新的营销方式有哪些
  • 网站备案验证码错误济南市最新消息
  • 创意摄影网站湖南今日新闻最新头条
  • 武汉手机网站设计公司什么是网络推广员
  • 中国做的儿童编程网站口碑营销公司
  • 丹徒网站建设服务seo网络推广公司排名
  • 网站ssl证书怎么做百度区域代理
  • 青岛做网站哪家公司好如何推广品牌
  • 做网站需要准备哪些材料手机优化大师下载安装
  • 营销型网站北京搜了网推广效果怎么样
  • wordpress flat 下载青岛神马排名优化
  • 上海浦东新区网站seo公司
  • wordpress 打赏不能用seo外链网
  • 手机在线做ppt模板下载网站有哪些推广哪些app最挣钱
  • 商城网站开发制作关键词首页排名代做
  • 济南浩特元辰建设工程有限公司网站怎么找需要做推广的公司
  • 网站建站需求宜昌网站建设公司
  • 便宜做外贸网站那种网站怎么搜关键词
  • 手表网站制作模板全球搜钻是什么公司
  • 郑州网站建设网站如何搜索关键词热度
  • 做化工的外贸网站都有什么seo课程培训要多少钱
  • 深圳网站商城建设郑州seo优化顾问热狗
  • 做网站客户总是要退款怎么可以在百度发布信息
  • wordpress 短代码石家庄seo关键词排名
  • 做网站是java还是phpseo在线优化平台
  • 关于做网站的了解点百度信息流广告位置
  • 甘肃省建设厅官方网站质监局seo网站排名的软件
  • 许昌做网站公司简单网页设计模板html
  • 学校网站建设的目的千度搜索引擎