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

Vuehtml2pdf的使用

Package Github:

https://github.com/kempsteven/vue-html2pdf
请查看演示站点和演示github以更容易地理解包的使用。

Demo Site:

https://vue-html2pdf-demo.netlify.com

Demo Github:

https://github.com/kempsteven/vue-html2pdf-demo

1、vue-html2pdf

vue-html2pdf将任何vue组件或元素转换为PDF, vue-html2pdf基本上只是一个vue包装器,并在幕后使用html2pdf.js。

2、Props

PropsThis props can seen in the Usage Part

PropsOptions(选项)Description(描述)
①show-layouttrue, falseShows the pdf-content slot, using this you can see what contents will be converted to PDF.(显示PDF-content槽,使用它可以看到什么内容将被转换为PDF。 )
②float-layouttrue, falseEnabled by default. If the props is set to false The props show-layout will be overridden. The layout will not float and the layout will ALWAYS show.(默认启用。 如果props设置为false,则props show-layout将被重写。 布局将不会浮动和布局将总是显示。)
③enable-downloadtrue, falseEnabled by default. When enabled the pdf will be downloaded and vise-versa.(默认启用。 当启用时,pdf将被下载,反之亦然。)
④preview-modaltrue, falseOnce you generate the pdf, PDF will be previewed on a modal, PDF will not be downloaded.(一旦您生成pdf, pdf将在一个模式上预览,pdf将不会被下载。 )
⑤paginate-elements-by-heightAny Number(任意数字)The number inputed will be used to paginate elements, the number will be in px units only.(输入的数字将用于对元素进行分页,该数字将以px为单位。)
⑥manual-paginationtrue, falseWhen enabled, the package will NOT automatically paginate the elements. Instead the pagination process will rely on the elements with a class “html2pdf__page-break” to know where to page break, which is automatically done by html2pdf.js.(启用时,包不会自动对元素进行分页。 相反,分页过程将依赖于具有“html2pdf__page-break”类的元素来知道分页在哪里,这是由html2pdf.js自动完成的 。)
⑦filenameAny String(任意字符串)给导出的pdf文件命名
⑧pdf-quality0 - 2 (Can have decimal) (可以带小数点)2 is the highest quality and 0.1 is the lowest quality, 0 will make the PDF disappear.(2是最高质量,0.1是最低质量,0会使PDF消失。)
⑨pdf-formata0, a1, a2, a3, a4, letter, legal, a5, a6, a7, a8, a9, a10This are the PDF formats (Paper Sizes)(这是PDF格式(纸张尺寸))
⑩pdf-orientationportrait, landscape(纸张、页面)纵向的,横向的)This are the PDF orientation.(这是PDF的方向。)
⑪pdf-content-widthAny css sizes (e.g. “800px”, “65vw”, “70%”)This is the PDF’s content width.(这是PDF的内容宽度。)
⑫html-to-pdf-optionshtml-to-pdf-options details hereThis prop gives a way to configure the whole html2pdf.js options.(这个支持提供了一种配置整个html2pdf.js选项的方法。)

3、html-to-pdf-options

NameTypeDefaultDescription
①marginnumber or array0PDF margin (in jsPDF units). Can be a single number, [vMargin, hMargin], or [top, left, bottom, right].(这是PDF的内容宽度。PDF页边距(以jsPDF单位)。 可以是单个数字,[vMargin, hMargin],或[上,左,下,右]。 )
②filenamestring‘file.pdf’The default filename of the exported PDF.(导出的PDF文件的默认文件名。)
③imageobject{type: ‘jpeg’, quality: 0.95}The image type and quality used to generate the PDF. See Image type and quality.(用于生成PDF的图像类型和质量。 参见图像类型和质量。)
④enableLinksbooleanfalseIf enabled, PDF hyperlinks are automatically added ontop of all anchor tags.(如果启用,PDF超链接将自动添加到所有锚标记的顶部。 )
⑤html2canvasobject{ }Configuration options sent directly to html2canvas (see here for usage).(配置选项直接发送到html2canvas(参考这里的用法)。 )
⑥jsPDFobject{ }Configuration options sent directly to jsPDF (see here for usage).(配置选项直接发送到jsPDF(参见这里的用法)。)

4、Events

This events can seen in the Usage Part

EventsDescription
@progressThis will return the progress of the PDF Generation. The event argument contains the progress of the PDF generation process.(这将返回PDF生成的进度。 event参数包含PDF生成过程的进度。 )
@startPaginationThis will be triggered on start of pagination process.(这将在分页过程开始时触发。)
@hasPaginatedThis will be triggered after the pagination process.(这将在分页过程之后触发。)
@beforeDownloadThis will be triggered before the PDF generation and download. The event arguments contains an object { html2pdf, options, pdfContent }, which can be used to have full control of html2pdf.js like e.g.(Add page count on each PDF page, Full control of jsPDF to design page, etc.), you will have to set the props :enable-download, :preview-modal to false so it will not generate the PDF.(这将在生成和下载PDF之前触发。 事件参数包含一个对象{html2pdf,选项,pdfContent},它可以用来有html2pdf.js的完全控制,例如(在每个PDF页面上添加页面计数,jsPDF设计页面的完全控制等),你必须设置道具:enable-download,:preview-modal为false,所以它将不会生成PDF。)
@hasDownloadedThis will be triggered after downloading the PDF. The event arguments contains the Blob File of the generated PDF. This will NOT be trigerred if the props enable-download AND preview-modal is set to false.(这将在下载PDF后触发。 事件参数包含生成的PDF的Blob文件。 这将不会被触发,如果道具启用下载和预览模式设置为false。)

相关文章:

  • java计算机毕业设计图书馆管理系统源码+系统+数据库+lw文档+mybatis+运行部署
  • 南京国家农创聚功能性农业主导产业 国稻种芯百团计划行动
  • A. Balance the Bits (思维构造)
  • k8s系列(二)——云计算相关概念
  • 数据挖掘学习笔记01——数据挖掘的基本流程
  • 分布式缓存Hazelcast的部署及与SpringBoot整合使用
  • 1.5 Elasticsearch文档的基本操作
  • 微电网|含分布式发电的微电网中储能装置容量优化配置(Matlab代码实现)
  • postgresql 服务器日志
  • c++ 中map 的find 用法
  • 《MeInGame: Create a Game Character Face from a Single Portrait 》论文解读
  • 实现多线程的方式
  • 精通Java必备的100道面试题——面向对象面试题
  • Tcmalloc内存分配算法的分析
  • 中国按摩器行业市场需求与投资规划分析报告
  • Java深入 - 深入理解Java集合
  • java中的hashCode
  • MaxCompute访问TableStore(OTS) 数据
  • Spring Boot快速入门(一):Hello Spring Boot
  • 半理解系列--Promise的进化史
  • 笨办法学C 练习34:动态数组
  • 基于Android乐音识别(2)
  • 计算机在识别图像时“看到”了什么?
  • 解决iview多表头动态更改列元素发生的错误
  • 力扣(LeetCode)357
  • 批量截取pdf文件
  • 优化 Vue 项目编译文件大小
  • ​软考-高级-系统架构设计师教程(清华第2版)【第9章 软件可靠性基础知识(P320~344)-思维导图】​
  • #include到底该写在哪
  • (+3)1.3敏捷宣言与敏捷过程的特点
  • (175)FPGA门控时钟技术
  • (bean配置类的注解开发)学习Spring的第十三天
  • (floyd+补集) poj 3275
  • (二)什么是Vite——Vite 和 Webpack 区别(冷启动)
  • (附源码)springboot“微印象”在线打印预约系统 毕业设计 061642
  • (附源码)ssm智慧社区管理系统 毕业设计 101635
  • (个人笔记质量不佳)SQL 左连接、右连接、内连接的区别
  • (离散数学)逻辑连接词
  • (未解决)jmeter报错之“请在微信客户端打开链接”
  • **登录+JWT+异常处理+拦截器+ThreadLocal-开发思想与代码实现**
  • *ST京蓝入股力合节能 着力绿色智慧城市服务
  • .chm格式文件如何阅读
  • .locked1、locked勒索病毒解密方法|勒索病毒解决|勒索病毒恢复|数据库修复
  • .net core 实现redis分片_基于 Redis 的分布式任务调度框架 earth-frost
  • .NET Micro Framework初体验(二)
  • .vue文件怎么使用_我在项目中是这样配置Vue的
  • /var/log/cvslog 太大
  • [ web基础篇 ] Burp Suite 爆破 Basic 认证密码
  • [ 英语 ] 马斯克抱水槽“入主”推特总部中那句 Let that sink in 到底是什么梗?
  • []常用AT命令解释()
  • [20170728]oracle保留字.txt
  • [ANT] 项目中应用ANT
  • [BT]BUUCTF刷题第9天(3.27)
  • [BZOJ2208][Jsoi2010]连通数
  • [CareerCup] 12.3 Test Move Method in a Chess Game 测试象棋游戏中的移动方法