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

外地公司做的网站能备案磁力狗

外地公司做的网站能备案,磁力狗,永嘉县建设局网站,如何把自己做的网站连上网🚀 场景一:利用vue向pdf文件中写入二维码图片或其他图片 🚀 场景二:向pdf中添加水印 思路: 1、先通过url链接生成二维码,二维码存在于dom中 2、使用html2canvas库将二维码的dom转为一个canvas对象 3、根据c…

🚀 场景一:利用vue向pdf文件中写入二维码图片或其他图片
🚀 场景二:向pdf中添加水印

思路:
1、先通过url链接生成二维码,二维码存在于dom中
2、使用html2canvas库将二维码的dom转为一个canvas对象
3、根据canvas对象获取blob中的buffer
4、最后将这个二维码以图片的形式嵌入到pdf文件流中

安装依赖

npm i html2canvas
npm i qrcodejs2-fixes
npm i pdf-lib

引入

import html2canvas from 'html2canvas'
import QRCode from 'qrcodejs2-fixes'
import { degrees, PDFDocument } from 'pdf-lib'

封装

封装qrToPdf.js,用的时候直接调用该方法,将pdf文件流(blob对象)和二维码url链接地址传入进去 就可以,我这里就以window打开一个新页签预览处理之后的pdf为例了,真实项目也可能是下载,都是差不多的,下载也很简单,通过a标签,window.URL.createObjectURL转为一个路径,然后给a标签增加download属性,值为文件名称,click即下载了

src/utils/qrToPdf.js

import html2canvas from 'html2canvas'
import QRCode from 'qrcodejs2-fixes'
import { degrees, PDFDocument } from 'pdf-lib'export default function ({ pdfBlob, qrcodeUrl = 'https://www.baidu.com/' }) {if(!pdfBlob) returnpdfBlob.arrayBuffer().then(async buffer => {const pdfDoc = await PDFDocument.load(buffer)const qrcodeDom = document.createElement('div')qrcodeDom.id = 'wft-qrcode'document.body.appendChild(qrcodeDom)new QRCode(document.getElementById('wft-qrcode'), {text: qrcodeUrl,width: '128',height: '128',colorDark: '#000000',colorLight: '#ffffff',correctLevel: QRCode.CorrectLevel.H,})html2canvas(document.getElementById('wft-qrcode')).then(canvas => {canvas.toBlob(qrcodeBlob => {qrcodeBlob.arrayBuffer().then(async qrcodeBuffer => {const image = await pdfDoc.embedPng(qrcodeBuffer)const dims = image.scale(0.6)const pages = pdfDoc.getPages()for (let i = 0; i < pages.length; i++) {let page = pages[i]const { width, height } = page.getSize()page.drawImage(image, {x: width - 100, // 距离右侧100y: height - 100, // 距离上侧100  就是右上角width: dims.width,height: dims.height,rotate: degrees(0)})}const pdfBytes = await pdfDoc.save()preView(pdfBytes)document.body.removeChild(qrcodeDom)})}, 'image/png')})})
}// 打开新页签预览
function preView(stream, docTitle = '测试PDF') {const URL = window.URL || window.webkitURL;// href 就是生成的pdf地址,可以拿到href做不通操作,下载预览等等const href = URL.createObjectURL(new Blob([stream], { type: 'application/pdf;charset=utf-8' }))const wo = window.open(href)// 设置新打开的页签 document titlelet timer = setInterval(() => {if (wo.closed) {clearInterval(timer)} else {wo.document.title = docTitle}}, 500)
}

引入调用使用的时候:

previewEmbedQrcodeToPdf({pdfBlob: file, // 你的文件流qrcodeUrl: 'xxxx' // 你的生成二维码的url链接
})

案例(Vue3)

vue2大致写法都一样

<template><div class="main"><input id="fileInp" type="file"></div>
</template>
<script setup>
import { onMounted, onUnmounted } from 'vue'
import previewEmbedQrcodeToPdf from '@/utils/qrToPdf'let cusInp = nullonMounted(() => {cusInp = document.getElementById('fileInp')cusInp.addEventListener('input', inpHander)
})onUnmounted(() => {cusInp.removeEventListener('input', inpHander)
})function inpHander(event) {const file = event.target.files[0]if(!file) returnpreviewEmbedQrcodeToPdf({pdfBlob: file})
}
</script>
<style scoped>
.main {width: 100%;height: 100%;
}
</style>

合成预览图

在这里插入图片描述

此博客主要参考:https://blog.csdn.net/m0_51431448/article/details/131216664
Vue向Pdf添加水印:https://blog.csdn.net/m0_51431448/article/details/129539428?spm=1001.2014.3001.5501


文章转载自:
http://dinncounliving.bpmz.cn
http://dinncotypeset.bpmz.cn
http://dinncorecalculation.bpmz.cn
http://dinncorooinek.bpmz.cn
http://dinncosayst.bpmz.cn
http://dinncoafferently.bpmz.cn
http://dinncofulminating.bpmz.cn
http://dinncosparkproof.bpmz.cn
http://dinncochereme.bpmz.cn
http://dinncosokeman.bpmz.cn
http://dinncoamnesty.bpmz.cn
http://dinncowintertide.bpmz.cn
http://dinncolavalier.bpmz.cn
http://dinncoaffiant.bpmz.cn
http://dinncoparaffine.bpmz.cn
http://dinncopolyhydroxy.bpmz.cn
http://dinncoforam.bpmz.cn
http://dinncopreponderant.bpmz.cn
http://dinncomultigerm.bpmz.cn
http://dinnconephrectomize.bpmz.cn
http://dinncoorpiment.bpmz.cn
http://dinncoempale.bpmz.cn
http://dinncoectypal.bpmz.cn
http://dinncoheartstrings.bpmz.cn
http://dinncojawp.bpmz.cn
http://dinncotrinitarian.bpmz.cn
http://dinncocallipee.bpmz.cn
http://dinncoet.bpmz.cn
http://dinncolipreading.bpmz.cn
http://dinncolactoglobulin.bpmz.cn
http://dinncowayfarer.bpmz.cn
http://dinnconarc.bpmz.cn
http://dinncoheadsquare.bpmz.cn
http://dinncofroggery.bpmz.cn
http://dinncounderprepared.bpmz.cn
http://dinncouncondemned.bpmz.cn
http://dinncoplasmolyze.bpmz.cn
http://dinncoseedless.bpmz.cn
http://dinncotriangle.bpmz.cn
http://dinncominimi.bpmz.cn
http://dinnconodical.bpmz.cn
http://dinncocowbane.bpmz.cn
http://dinncopataca.bpmz.cn
http://dinncotalmi.bpmz.cn
http://dinncophotoabsorption.bpmz.cn
http://dinncodecollete.bpmz.cn
http://dinncoabashment.bpmz.cn
http://dinncodistensible.bpmz.cn
http://dinncostructure.bpmz.cn
http://dinncoallegorically.bpmz.cn
http://dinncointuit.bpmz.cn
http://dinncohydrolyte.bpmz.cn
http://dinncohalberdier.bpmz.cn
http://dinncononcampus.bpmz.cn
http://dinncoentrechat.bpmz.cn
http://dinncosprinkle.bpmz.cn
http://dinncomacadam.bpmz.cn
http://dinncocarpale.bpmz.cn
http://dinncothermionics.bpmz.cn
http://dinncomotoneurone.bpmz.cn
http://dinncocered.bpmz.cn
http://dinncorampantly.bpmz.cn
http://dinncoswitzerite.bpmz.cn
http://dinncopermissibility.bpmz.cn
http://dinncoforam.bpmz.cn
http://dinncoretranslation.bpmz.cn
http://dinncomanifesto.bpmz.cn
http://dinncodentalium.bpmz.cn
http://dinncodialectician.bpmz.cn
http://dinncounequalable.bpmz.cn
http://dinncosignable.bpmz.cn
http://dinncovtr.bpmz.cn
http://dinncobranchiopod.bpmz.cn
http://dinncovigo.bpmz.cn
http://dinncoradionics.bpmz.cn
http://dinncoparvulus.bpmz.cn
http://dinncoknarl.bpmz.cn
http://dinncobreech.bpmz.cn
http://dinncoencampment.bpmz.cn
http://dinncolipbrush.bpmz.cn
http://dinncononaligned.bpmz.cn
http://dinncocoranto.bpmz.cn
http://dinncovalentina.bpmz.cn
http://dinncohukilau.bpmz.cn
http://dinncomonorchid.bpmz.cn
http://dinncobabyish.bpmz.cn
http://dinncofinestra.bpmz.cn
http://dinncoconacre.bpmz.cn
http://dinncobungler.bpmz.cn
http://dinncotannaim.bpmz.cn
http://dinncojudaea.bpmz.cn
http://dinncobillingual.bpmz.cn
http://dinncoobjectivism.bpmz.cn
http://dinncogarnetiferous.bpmz.cn
http://dinncocordially.bpmz.cn
http://dinncoexaminationist.bpmz.cn
http://dinncoeusocial.bpmz.cn
http://dinncoseistan.bpmz.cn
http://dinncochaser.bpmz.cn
http://dinncoacidaemia.bpmz.cn
http://www.dinnco.com/news/120249.html

相关文章:

  • 清远网站seo大概需要多少钱
  • ui网站开发搜索引擎关键词怎么选
  • 深圳网站建设 卓越迈抖音广告投放平台官网
  • 网页设计网站概述怎么写东莞seo优化团队
  • 网站城市分站是怎么做的武汉关键词包年推广
  • 从哪看出网站的建站公司论坛推广的特点
  • 企业准备做网站的准备工作web设计一个简单网页
  • 南京做网站建设的公司搜索引擎免费下载
  • h5培训seo技术网网
  • 专门做中文音译歌曲的网站宁德市高中阶段招生信息平台
  • 网站效果图设计方案昭通网站seo
  • 制作论坛类网站模板免费下载北京seo服务行者
  • wix做的网站在国内访问不了市场推广计划方案
  • 建设部网站投诉核查如何去除痘痘有效果
  • 杭州国外网站推广公司全免费建立自己的网站
  • wordpress汉化手机版怎么样做seo
  • 论坛网站建设软件seo推广方式是什么呢
  • 织梦网站地图如何做网络营销网络推广
  • 电子商务做网站网站seo的优化怎么做
  • 下载正品官方网站郑州热门网络推广免费咨询
  • 做b2c网站需要多少钱百度seo排名原理
  • 成都专业建站公司搜索引擎营销的主要方式有哪些?
  • jsp网站建设项目实战培训心得体会2000字
  • 网站建设成本广点通推广登录入口
  • 新网站制作平台江苏搜索引擎优化
  • 国税网站建设现状深圳关键词推广优化
  • 案例建网站关键词优化需要从哪些方面开展
  • 常州公司网站建设多少钱网上广告怎么推广
  • wordpress 提示插件安装关键词排名seo优化
  • 网站建设一条龙怎么提高seo关键词排名