使用 pdfkit 打印条码

问题描述

我想像图像一样在 nodejs 中打印珠宝条形码。

enter image description here

我的代码

  var doc = new PDFDocument({
   size: [200,100]
  });
  doc.font('Times-Roman')
      .fontSize(7)
      .text("1.49G",100,4);
  doc.font('./public/fonts/LibreBarcode39-Regular.ttf')
      .fontSize(18)
      .text('12345678',145,4,{align:"right"});
  doc.font('Times-Roman')
        .fontSize(7)
        .text("DC1",20)
        .text("120,000MMK",20,{align:"left"});
  doc.end();
  doc.pipe(fs.createWriteStream("./public/upload/barcode/doc.pdf"));

它的作用是

enter image description here

我有两个问题:

  1. 当我打印条码时它会变成纵向。

enter image description here

  1. 然后,大小:[200,100] 不是我真正的想法。条形码底部有很多额外的图片(2)。我想要的大小是 [200,50]。当我将大小从 [200,100] 更改为 [200,50] 时,会出现许多模板。 size [200,50] 足以设计我想要的条码。但它分裂成图(4)。

enter image description here

任何帮助将不胜感激!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)