mirror of
https://github.com/foliojs/pdfkit.git
synced 2026-02-01 16:56:57 +00:00
1
Printing PDFs with IPP
Jeremy Woertink edited this page 2015-01-07 09:55:09 -08:00
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();