中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當前位置: 首頁 > news >正文

公司網(wǎng)站是否做地方分站如何找做網(wǎng)站的公司

公司網(wǎng)站是否做地方分站,如何找做網(wǎng)站的公司,wordpress nas 外網(wǎng),北京金港建設股份有限公司網(wǎng)站準備做的系統(tǒng)中出現(xiàn)了 想導出當前頁面的png或者pdf設計數(shù)據(jù)較多后端做可能比較麻煩 就自己研究了一下 1、安裝html2canvas 、jspdf包 npm install --save html2canvas // 可以將dom元素轉(zhuǎn)為一張圖片 npm install --save jspdf // 導出為PDF格式 2、vue組件中引用&#x…

準備做的系統(tǒng)中出現(xiàn)了 想導出當前頁面的png或者pdf設計數(shù)據(jù)較多后端做可能比較麻煩 就自己研究了一下

1、安裝html2canvas?、jspdf包

npm install --save html2canvas   // 可以將dom元素轉(zhuǎn)為一張圖片
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">需要截取的內(nèi)容區(qū)域我想測試導出是否可行</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'); // 創(chuàng)建一個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畫布內(nèi) 可以跨域請求外部鏈接圖片, 允許跨域請求。,// 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();}}}// 可動態(tài)生成pdf.save(`文件名.pdf`);});}
</script>

http://m.risenshineclean.com/news/48315.html

相關文章:

  • it運維需要學哪些知識搜索優(yōu)化師
  • 哪個網(wǎng)站反盜版做的最好域名注冊網(wǎng)站查詢
  • 免費企業(yè)建站源代碼搜索引擎廣告推廣
  • 廈門做網(wǎng)站優(yōu)化多少錢百度競價排名什么意思
  • 做網(wǎng)站 最好的開源cms哈爾濱seo服務
  • 網(wǎng)站管理助手 ftp2021年網(wǎng)絡十大關鍵詞
  • wordpress sparklingseo關鍵詞優(yōu)化怎么收費
  • 關于政府網(wǎng)站建設的實施意見個人網(wǎng)頁免費域名注冊入口
  • 企業(yè)信息填報登錄百度關鍵字優(yōu)化價格
  • 公司網(wǎng)站建設費用包括知名網(wǎng)絡軟文推廣平臺
  • 做電商網(wǎng)站的感想免費b站推廣網(wǎng)站在線
  • 制作網(wǎng)站上海網(wǎng)絡營銷公司哪家好
  • python 網(wǎng)站開發(fā)實戰(zhàn)百度下載app下載
  • 免費的黃金軟件seo優(yōu)化價格
  • 假冒網(wǎng)站能通過備案登記嗎手機怎么創(chuàng)建自己的網(wǎng)站平臺
  • 網(wǎng)站的外鏈情況關鍵詞優(yōu)化搜索排名
  • 網(wǎng)站底部信息怎么注冊百度賬號
  • 如何讓網(wǎng)站不被收錄電商代運營收費標準
  • 如何在國稅網(wǎng)站做票種核定網(wǎng)站開發(fā)從入門到實戰(zhàn)
  • 新手學做網(wǎng)站要花錢么大數(shù)據(jù)營銷推廣精準粉
  • 成都企業(yè)網(wǎng)站建設方案天津網(wǎng)絡推廣seo
  • 網(wǎng)站開發(fā)用什么寫seo課程培訓
  • html中文網(wǎng)aso優(yōu)化什么意思
  • 做網(wǎng)站需要icp經(jīng)營許可證網(wǎng)絡營銷師培訓費用是多少
  • 石家莊做網(wǎng)站科技公司南昌做seo的公司有哪些
  • 如何再騰訊云服務器做網(wǎng)站百度關鍵詞排名怎么靠前
  • 最專業(yè)的外貿(mào)網(wǎng)站建設廣州關鍵詞seo
  • 一般app開發(fā)費用seo外包公司費用
  • betheme做網(wǎng)站怎么樣網(wǎng)店網(wǎng)絡營銷與推廣策劃書
  • 網(wǎng)站布局結(jié)構(gòu)如何引流客源最快的方法