tro*_*oyz 5 node.js node-pdfkit
我正在尝试使用节点的 pdfkit 制作 PDF,但遇到一些与文本宽度相关的问题。
我想要的结果是这样的。
Overall comments: This is the comment
that will display here bla bla
extra text here
Run Code Online (Sandbox Code Playgroud)
但我当前的代码得到的是这样的
Overall comments: This is the comment
that will display here blab bla extra text here
Run Code Online (Sandbox Code Playgroud)
为了编写这段文字,我使用以下代码:
doc.font('Courier-Bold').text(padRight('Overall Comments:',28),{continued: true});
doc.font('Courier').text(audit.comment,{width: 100,align: 'justify'});
Run Code Online (Sandbox Code Playgroud)
其中audit.comment是右侧的文本,padRight返回固定大小为28的字符串,在右侧添加空格。
它似乎忽略了宽度选项或者我不知道如何使用它。
小智 0
使用“继续”后似乎文本选项被忽略。我的解决方案是在实际文本之前添加空文本。
例如。
doc.font('Courier-Bold').text(padRight('Overall Comments:',28),{continued: true});
doc.text('');
doc.font('Courier').text(audit.comment,{width: 100,align: 'justify'});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2163 次 |
| 最近记录: |