vue 使用htmlToPdf遇到的坑

Vue导出页面为PDF格式高清(亲测有效) 通过在网上查阅资料,说一下思路.就是将页面转换成图片格式.然后通过图片的base64码.生成PDF… 做个整理总结,如果也你实现了请留下你点赞的小手 1 、首先我们要安装两个包.分别是: 注意: 如果npm下载较慢,建议可以考虑换成cnpm下载 下载完这两个包之后项目有可能会报错,不要慌张,如果英语不好看不懂,复制到百度,就会解决(我当时报错的内容是Module build failed: Error: ENOENT: no such file or directory, scandir...,就是.. 阅读详情

1、使用htmlToPdf实现pdf下载中遇到的坑!!下载的表格中有一张图片,控制台一直报错在这里插入图片描述
然后我查到的资料都让修改img crossorigin=anonymous ,一直没有作用
后来感觉改的方向不对就开始查阅htmlToPdf文档

2、解决办法
如果再vue中使用htmlToPdf报上图所示错误
设置htmlToPdf参数allowTaint:false;useCORS: true
在这里插入图片描述
这样就解决了Failed to execute ‘toDataURL’ on ‘HTMLCanvasElement’: Tainted canvases may not be exported.报错问题

Vue页面转PDF文件并下载 安装插件 npm install -S jspdf npm install -S html2canvas 使用: 1)新建htmlToPdf.js(可放在libs文件下) import html2Canvas from 'html2canvas' import JsPDF from 'jspdf' export default{ install (Vue, options) { Vu... 阅读详情

相关推荐

「Vue2架构」Vue2实现区域预览和打印功能

Vue2实现区域预览和打印功能。

拥抱AI Design 1135

js 将html转换成pdf,jsPDF将HTML转换成PDF

我试图将HTML转换成PDF和我在ASP.NET MVC5工作是我的代码:jsPDF将HTML转换成PDF@model Ebok.Models.AtmClaimReportDetailsInfoViewModel@{ViewBag.Title = "Dzienny raport rozliczenia transakcji bankomatu "+Model.AtmPid+" sieci "+Mo...

weixin_33583401的博客 323

记录Nvidia AGX Orin的配置日常(二)设置上电自动开机和远程桌面

因为要拿AGX作为机器人的主控板,所以需要给他设置一下通电后无需按电源键就自动开机,然后再配置一下远程桌面。

AutomaticForever的博客 1366

使用vue-pdf实现文档在线预览报错(this.pdfSrc.then is not a function)

使用vue-pdf实现文档在线预览报错 最近项目需要实现移动端在线预览PDF文件的功能,最终使用了vue-pdf这个组件,使用vue-pdf组件时候,百度了它的使用方法,但大部分都一样,而且使用了还报错(下图)。 后来看了 vue-pdf 代码仓库发现,百度到的使用方法少了个 promise,我不知道他们的为什么能够直接成功,但是如果你的也报错了,可以试试我的操作。 不要忘记定义变量pdfSrc、numPages。 <pdf v-for="i in numPages" :key="i"

andy_boke的博客 3430

5G NR LDPC码(2)—— 从基图到速率匹配:解码5G高速数据信道的标准化设计

本文深入解析了5G NR LDPC码的标准化设计流程。从作为核心骨架的基图(BG1/BG2)出发,详细阐述了其如何通过扩展因子Z灵活生成实际校验矩阵,并协同传输块大小计算与分段策略。文章重点剖析了基于循环缓存和冗余版本的速率匹配机制,以及其如何高效支撑增量冗余混合自动重传请求,从而确保5G高速数据信道在复杂环境下的可靠与高效传输。

weixin_29206669的博客 274

E-Prime脑电实验打mark全攻略:从端口查询到串并口实战(附常见问题解决)

本文提供了E-Prime脑电实验打mark的完整实战指南,涵盖端口查询、并口与串口配置的核心步骤及常见问题解决。文章深入解析了mark原理,并详细介绍了通过E-Basic脚本和Serial设备对象发送信号的两种方法,帮助研究者实现E-Prime与脑电设备的高精度时间同步,确保实验数据可靠性。

4k5l6j7h8的博客 357

pdf.js报错 pattern.at is not a function

在你的 JavaScript 代码中,你遇到了错误 pattern.at is not a function,这通常是因为 pattern 数组或类数组对象没有 at 方法。at 方法是 ECMAScript 2022 (ES13) 中引入的一个新方法,用于返回数组或类数组对象中指定索引的元素,如果索引超出范围,则返回 undefined。但是,并非所有环境都支持这个新方法,特别是如果你的代码在较旧的浏览器或 JavaScript 环境中运行,就可能会遇到这个问题。

Zhm18508的博客 1017

群晖NAS实战:从零部署Container Manager与Docker代理配置全攻略

本文详细介绍了在群晖NAS上从零部署Container Manager与配置Docker代理的完整流程。针对国内用户常见的镜像拉取问题,提供了图形化界面与SSH命令行两种解决方案,并分享了MySQL容器部署的实战案例。文章特别强调了网络配置技巧和日常维护方法,帮助用户高效管理NAS上的容器应用。

weixin_29254673的博客 1315

Js:html转pdf插件总结(纯前端)

pdfmake默认不支持中文,所以需要安装字体文件。

努力的nana 1万+

从零开始:Vivado中自定义串口通信IP核的完整实现

本文详细介绍了在Vivado中从零开始实现自定义串口通信IP核的完整流程,包括Verilog核心代码编写、仿真验证、IP核封装与参数化配置技巧。通过AXI-Lite总线实现动态配置,提升FPGA开发效率,适用于各种嵌入式系统通信需求。

weixin_29274969的博客 326

龙虾 Skill 技能库|OpenClaw+Hermes 全集成 一键调用所有 AI 技能

龙虾 Skill 技能库、OpenClaw、Hermes Agent、AI 技能集成、本地 AI 自动化、办公工具、数字员工

weixin_42219287的博客 626

htmlToPdf

htmlToPdf

weixin_46087919的博客 636

VIPER22A实战:从零搭建15W非隔离电源,附BUCK电路调试心得

本文详细介绍了使用VIPER22A芯片从零搭建15W非隔离电源的全流程,重点解析BUCK电路设计与调试技巧。通过核心参数计算、PCB布局优化和效率提升方案,帮助工程师快速掌握DC-DC电源设计要点,实现高效稳定的电源转换。

redis7keeper的博客 673

vue3将页面导出成PDF文件(完美解决图片、表格内容分割问题)

【代码】vue3将页面导出成PDF文件(完美解决图片、表格内容分割问题)

DZQ1223的博客 1万+

从零到一:STM32G431的DSP库集成与FFT实战避坑指南

本文详细介绍了在STM32G431微控制器上集成CMSIS-DSP库并进行FFT实战开发的完整流程。重点解析了通过CubeMX和Keil环境配置DSP库的关键步骤、编译器宏定义陷阱及解决方案,并提供了FFT算法优化、内存管理及常见问题诊断的实用技巧,帮助开发者高效实现嵌入式信号处理应用。

oauth7security的博客 771

最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版

Part-E1-SDIO-Specification-Ver4.00-Final-120220.pdf:最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版,包括SDIO 接口的外设,SDIO 接口官方协议等。

vue项目中 页面生成pdf并下载,vue 中页面转PDF

第一步、安装插件 // 第一个.将页面html转换成图片 npm install --save html2canvas // 第二个.将图片生成pdf npm install jspdf --save  定义全局函数,创建一个htmlToPdf.js文件在指定位置. // 导出页面为PDF格式 import html2canvas from "html2canvas" import JSPDF ...

yuenandehutu的博客 1万+

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

vue使用jspdf_Vue 结合html2canvas和jsPDF实现html页面转pdf

实践环境win10Vue 2.9.6axios 0.18.0html2canvas 1.0.0-rc.3jspdf 1.5.3安装 html2canvas进入vue项目所在目录,然后执行以下安装命令cd /d E:\MyProjects\TMP\frontendE:\MyProjects\TMP\frontend>npm install html2canvas安装jspdf进入vue项目所在...

weixin_39603357的博客 427

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

vue + jspdf

vue 页面 <el-button @click="testPdf">导出PDF文件</el-button> <div id="container" > <el-button type="danger">危险按钮</el-button> <span>{{ t1 }}</span> </div> js代码 methods: { testPdf() { // this.dialogVis

mhbsoft的博客 2955

vue导出含echarts的html | PDF

要导出的vue组件如下: <div id="id" ref="resume"> <button @click="downloadHtml('报告')">html</button> <button @click="getPdf('id',报告')">pdf</button> <situation><...

weixin_34308389的博客 3565

Vue使用jsPdf将页面导出成pdf文件

1 、我们要添加两个模块 ①第一个.将页面html转换成图片 npm install --save html2canvas ②第二个.将图片生成pdf npm install jspdf --save 2、定义全局函数..创建一个htmlToPdf.js文件在指定位置.我个人习惯放在('src/components/utils/htmlToPdf') 文件路径...

weixin_30851867的博客 3233

vue+file-saver+xlsx+htmlToPdf+jspdf实现本地导出PDF和Excel

vue项目将页面导出excel格式和pdf格式

DevelopmentW的博客 1181

vue将页面导出pdf,vue导出pdf

vue导出pdf 新需求:需要前端下载把当前html下载成pdf文件 菜鸟觉得牛逼啊,这必须记录下来嗷嗷嗷嗷 1、第一步:我们要添加两个模块 //第一个:将页面html转换成图片 npm install --save html2canvas //第二个:将图片生成pdf npm install jspdf --save 2、第二步: 定义全局函数…创建一个htmlToPdf.js文件在指定位置.我个人习惯放在('src/components/utils/htmlToPdf’)中 htmlToPdf.js文

weixin_45869649的博客 1万+

vue html页面中部分div转pdf

通过html2canvas先将html转化为canvas,再通过canvas.toDataURL将canvas转化为图片 main.js中 import htmlToPdf from '@/components/utils/htmlToPdf' Vue.use(htmlToPdf) vue文件中 <template> <button type="primary" @click="getPdf()">保 存</button> <div id="pdfD.

yangchuangxyz的博客 853

vue中实现将页面或者div内容导出为pdf格式

vue中实现将页面或者div内容导出为pdf格式

Mr_115的博客 3214
上一篇: vue微信、支付宝支付
下一篇: element table合计(可点击,自定义值,修改样式,第一行展示)
前端小小白~
博客等级 码龄7年 16粉丝 24原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值