html - 打印列表时 pdfMake 和 html-to-pdfmake 的问题
问题描述
我正在尝试从查询到数据库生成 pdf,其中信息具有 HTML 代码,如列表。<p>DDDD</p><ol><li>asdasdas</li><li>asdasdasd</li><li>asdasdasd</li></ol><ul> <li> sdasdasd </li> </ul>
安装pdfmake
and后html-to-pdfmake
,我将它们导入到我的 component.ts
const pdfMake = require('node_modules/pdfmake/build/pdfmake')
const pdfFonts = require('node_modules/pdfmake/build/vfs_fonts')
pdfMake.vfs = pdfFonts.pdfMake.vfs
const htmlToPdfmake = require('html-to-pdfmake')
在某些时候我发送调用它生成的方法创建我的pdf
savePDF() {
console.log(this.reConsulta)
const documentDefinition = {
pageSize: 'A5',
// by default we use portrait, you can change it to landscape if you wish
pageOrientation: 'landscape',
// [left, top, right, bottom] or [horizontal, vertical] or just a number for equal margins
pageMargins: [5, 100, 5, 10],
content: [
{ text: htmlToPdfmake(this.reConsulta.medicamentos) },
{ text: htmlToPdfmake(this.reConsulta.metodo), absolutePosition: { x: 320, y: 100 } },
],
}
pdfMake.createPdf(documentDefinition).open()
}
此时this.reConsulta.medicamentos
有前一个列表的值<p>DDDD</p><ol><li>asdasdas</li><li>asdasdasd</li> <li> asdasdasd </li> </ol><ul><li>sdasdasd</li> </ul>
但是当创建 pdf 时,列表不会显示,但是其他 html 标签如<b> </b>
<i> </i>
格式化没有问题。
解决方案
推荐阅读
- windows - 从 repo 克隆时,Windows 会更改符号链接文件
- kubernetes - Kubernetes 放置会导致 Pod 永远重启
- python-3.x - 删除 k 个元素后的最大不同元素
- javascript - 如何在我的 django 聊天应用程序中录制用户音频?
- c# - 通过 WinForms 执行 OpenRowset 查询时必须声明表变量“@P1select”
- kubernetes - K8S:如何删除具有 0 个副本的部署
- java - 运算符 + 未定义参数类型 char[], int
- javascript - 以最大长度限制输入
- area - 如何在 PDFLIB 中设置显示区域
- python - 本地进口和包进口有什么区别?