2017-05-09 73 views
0

我有一個用戶必須完成的表單。 然後我將這些信息保存到數據庫中。使用node.js打印帶有條形碼的標籤

而且我想打印帶有表單信息的標籤。

部分信息需要以條形碼格式打印。

我嘗試了一些庫,如fluentreports(這允許我生成一個帶有信息的pdf,它不能生成條形碼),條形碼,jsbarcode,symbologi ......這些都不適合我。

任何人都可以幫助我/推薦一些圖書館來做到這一點?

謝謝!

+0

您可以冒險猜測爲什麼沒有嘗試過嗎?你遇到了什麼問題?你提到的其中一些庫每天都會被其他人使用。 –

+0

我解決了所有問題! –

回答

2

解決方案,它適用於我,只使用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(); 
} 
相關問題