Mar*_*ers 7 pdf pdf-generation node.js
Node-pdfkit http://pdfkit.org/index.html
我使用nodejs pdfkit生成pdf.我希望能够在一行中加粗或斜体.看起来pdfkit不支持这个,所以我想知道是否有人做过类似的事情?
真正有用的是调用doc.text函数,但让文档保留它的x位置,以便我可以执行以下操作.
doc.text('some words then ');
doc.font('Helvetica-Oblique');
doc.text('italic');
doc.font('Helvetica');
doc.text(' then the remaining words');
Run Code Online (Sandbox Code Playgroud)
并看到输出:
有些话则斜体那么剩下的话.
现在它每个文本函数输出一行.
有人知道这样做的好方法吗?
ej4在此拉取请求中添加了此功能https://github.com/devongovett/pdfkit/pull/60
它还没有被合并到主项目中,所以我最终自己分发了pdfkit,包括ej4s的变化以及我自己的一些变化.
基本结果是更改可以添加
continued: true
Run Code Online (Sandbox Code Playgroud)
到选项对象.然后Pdfkit会记住插入位置并返回到下一行文本的那个位置.
请参阅:使用pdfkit时,我可以在同一段落中混合字体权重吗?
pdf.text('Hello ', LEFT, 200, {
//here it is,
lineBreak : false
}).font(bold).text('World!');
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5147 次 |
| 最近记录: |