UNPKG

740 BJavaScriptView Raw
1#!/usr/bin/env node
2
3const HTML5ToPDF = require("../lib")
4const path = require("path")
5
6const run = async () => {
7 const html5ToPDF = new HTML5ToPDF({
8 inputPath: path.join(__dirname, "assets", "basic.html"),
9 outputPath: path.join(__dirname, "..", "tmp", "output.pdf"),
10 templatePath: path.join(__dirname, "templates", "basic"),
11 include: [
12 path.join(__dirname, "assets", "basic.css"),
13 path.join(__dirname, "assets", "custom-margin.css"),
14 ],
15 })
16
17 await html5ToPDF.start()
18 await html5ToPDF.build()
19 await html5ToPDF.close()
20}
21
22(async () => {
23 try {
24 await run()
25 console.log("DONE");
26 } catch (error) {
27 console.error(error)
28 process.exitCode = 1
29 } finally {
30 process.exit()
31 }
32})();
33