如何在node.js中使用pdfkit创建带有项目列表的文本

How to create text with Bulleted lists using pdfkit in node.js?

本文关键字:创建 项目 列表 文本 pdfkit node js      更新时间:2023-09-26

我从昨天开始就一直在制作Pdf格式的报告。我已经通过pdfkit模块。看起来用起来很酷。我的要求是用项目符号列出文本。我已经试过了

     var doc = new PDFDocument();
     doc.pipe(fs.createWriteStream('userReport.pdf'));
     doc.fillColor("#B22222")
     .fontSize(25)
     .text('Users Count', 250,60)
     .moveDown(0.5); 

它正在创建文本,但我想要带子弹的文本。如何做到这一点?

简单,对清单

 .list()

您可以在

查看一些样品
https://github.com/devongovett/pdfkit/tree/master/docs

// list params: array, x, y, other params
doc.list([1, 2, 3], 50, 50, {
  // this is how automatic line wrapping will work if the width is specified
  width: 100,
  align: 'left',
  listType: 'bullet',
  bulletRadius: 0.01, // use this value to almost hide the dots/bullets
});

这就是我的工作方式,我希望它能帮助到别人