-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathexample.js
More file actions
33 lines (28 loc) · 1.01 KB
/
example.js
File metadata and controls
33 lines (28 loc) · 1.01 KB
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
'use strict';
const fs = require('fs');
const invoice_generator = require('./index');
if (process.argv.length < 4) {
console.log('node example.js <invoice.json> <output.pdf>');
process.exit(2);
}
const input_filename = process.argv[2];
const output_filename = process.argv[3];
const invoice = JSON.parse(fs.readFileSync(input_filename));
const output_stream = fs.createWriteStream(output_filename);
invoice_generator(invoice, output_stream, {
currency: 'PLN',
footer: {
align: 'center',
text: 'XYZ sp. z o.o.\n' +
'Kapitał zakładowy: 50.000,00 zł\n' +
'Sąd Rejonowy dla Wrocławia - Fabrycznej we Wrocławiu\n' +
'VI Wydział Gospodarczy Krajowego Rejestru Sądowego\n' +
'Nr KRS: 0000000000 • REGON: 000000000 • NIP: 000-00-00-000',
},
stripBuyerCountry: 'PL',
info: {
Producer: 'rbx platform',
Creator: 'invoice module',
},
});
console.log(`Saved invoice from '${input_filename}' to '${output_filename}'`);