-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Printing PDFs with IPP
Jeremy Woertink edited this page Jan 7, 2015
·
1 revision
Using the IPP package to print PDFs.
var ipp = require("ipp"),
PDFDocument = require("pdfkit");
var doc = new PDFDocument({margin:0});
doc.fontSize(24);
doc.text("Hello World", {align: 'center'});
// Use your printer URL here. It must support IPP
var printURL = "http://localhost:631/printers/Lanier_MP_3500";
var printer = ipp.Printer(printURL);
var buffers = [];
doc.on('data', buffers.push.bind(buffers));
doc.on('end', function () {
var file = {
"operation-attributes-tag":{
"requesting-user-name": "User",
"job-name": "Print Job",
"document-format": "application/pdf"
},
data: Buffer.concat(buffers)
};
printer.execute("Print-Job", file, function (err, res) {
console.log("Printed: "+res.statusCode);
});
});
doc.end();