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