-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
42 lines (36 loc) · 1.2 KB
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
let ipp = require("ipp");
let PDFDocument = require("pdfkit");
let fs = require('fs');
let doc = new PDFDocument;
const remote_printer_host = "http://13.233.201.124:3000"
doc.text("Hello World");
let buffers = [];
doc.on('data', buffers.push.bind(buffers));
doc.on('end', function () {
console.log('file buffurs: ', Buffer.concat(buffers));
let printer = ipp.Printer(remote_printer_host, {version:'1.0'});
let print_file_job = {
"operation-attributes-tag":{
"requesting-user-name": "User",
"job-name": "Print Job",
// "document-format": "application/octet-stream"
"document-format": "application/octet-stream"
},
data: Buffer.concat(buffers)
};
// let get_atr_job = {
// "operation":"Get-Printer-Attributes",
// "operation-attributes-tag": {
// "attributes-charset": "utf-8",
// "attributes-natural-language": "en",
// "printer-uri": 'my_printer'
// }
// }
printer.execute("Print-Job", print_file_job, function (err, res) {
console.dir(res);
});
fs.writeFile("test.pdf", Buffer.concat(buffers) , (err) => {
console.log(err)
})
});
doc.end();