node.js - 使用node.js打印带有条形码的标签

标签 node.js label barcode-printing

我有一个用户必须填写的表格。 然后我将这些信息保存到数据库中。

我想打印一个包含表单信息的标签。

其中一些信息需要以条形码格式打印。

我尝试了一些库,例如 Fluentreports(这允许我生成包含信息的 pdf,它无法生成条形码)、条形码、jsbarcode、symbologi...这些都不适合我。

任何人都可以帮助我/推荐一些库来做到这一点吗?

谢谢!

最佳答案

它对我有用的解决方案,仅使用 PDFKit。 这解决了条形码的问题。

var PDFDocument = require('pdfkit');
var fs = require('fs');

exports.printEti1015 = function printEti1015(formData){

    var marginTB = 19;
    var marginLR = 16;
    // create a document and pipe to a blob
    var doc = new PDFDocument({
        size: [432, 288] // a smaller document for small badge printers
    });

    doc.pipe(fs.createWriteStream('output.pdf'));

    //codebar
    doc.font("C:/Windows/Fonts/c39n2_0.ttf")
        .fontSize(39)
        .text ("*2017050800001*",0+marginLR,0+marginTB,{width:195,height:40,align:'center'})
    doc.font('Times-Roman')
        .fontSize(12)
        .text("codebar: 2017050800001",0+marginLR,35+marginTB,{width:195,height:20,align:'center'});

    doc.end();
}

关于node.js - 使用node.js打印带有条形码的标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43865595/

相关文章:

java - 如何添加或更改 JMenuItem 上的标签?

node.js - 测试 fastify 路由时如何修复 "not ok timeout!"?

node.js - 如何将 http 代理与 node.js https 一起使用?

node.js - 当特定函数运行时阻塞事件循环

python - 生成二维条形码并排列在网格上以进行批量打印

c# - 这个计算 Code128 条码校验位的代码是否正确?

node.js - V8引擎中Function::Call的第一个参数是什么意思?

c++ - 如果达到结束条件,是否可以在 C++ 中退出 for before time?

r - ggplot 线的选择性标记