Generate PDF automatically
This commit is contained in:
parent
0f57a2c305
commit
e31c7ef854
6 changed files with 1502 additions and 132 deletions
4
README
4
README
|
|
@ -1,4 +1,4 @@
|
|||
1. npm run build or node.index.js
|
||||
1. npm run build or node index.js
|
||||
2. copy ./pub to public url
|
||||
|
||||
Use "print to PDF" to sync PDF file manually.
|
||||
Use "print to PDF" to sync PDF file manually if needed.
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -1,6 +1,13 @@
|
|||
html {
|
||||
font: normal small/1.5 apple-system, system-ui, BlinkMacSystemFont, Segoe UI,
|
||||
Roboto, Helvetica Neue, Arial, sans-serif;
|
||||
font:
|
||||
normal small/1.5 apple-system,
|
||||
system-ui,
|
||||
BlinkMacSystemFont,
|
||||
Segoe UI,
|
||||
Roboto,
|
||||
Helvetica Neue,
|
||||
Arial,
|
||||
sans-serif;
|
||||
background-color: var(--bg-color, #fff);
|
||||
color: var(--bg-color, #444);
|
||||
}
|
||||
|
|
@ -31,7 +38,9 @@ figure {
|
|||
}
|
||||
a {
|
||||
color: var(--bg-color, #444);
|
||||
transition: background-color 0.3s ease-out, border-bottom-color 0.3s ease-out;
|
||||
transition:
|
||||
background-color 0.3s ease-out,
|
||||
border-bottom-color 0.3s ease-out;
|
||||
}
|
||||
p:first-child {
|
||||
margin-top: 0;
|
||||
|
|
@ -229,18 +238,29 @@ the upcoming Container queries was a thing.
|
|||
}
|
||||
|
||||
@page {
|
||||
padding: 0;
|
||||
padding: 2cm 0;
|
||||
margin: 0;
|
||||
size: A4 portrait;
|
||||
}
|
||||
|
||||
@media print {
|
||||
body {
|
||||
padding: 1cm;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
[href$="pdf"] {
|
||||
display: none;
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
a {
|
||||
border: none !important;
|
||||
color: #000 !important;
|
||||
}
|
||||
|
||||
.education,
|
||||
.projects,
|
||||
.work {
|
||||
page-break-before: always;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
17
index.js
17
index.js
|
|
@ -4,6 +4,22 @@ var layouts = require("metalsmith-layouts");
|
|||
var markdown = require("metalsmith-markdown-remarkable");
|
||||
var permalinks = require("@metalsmith/permalinks");
|
||||
var static = require("metalsmith-static");
|
||||
var puppeteer = require("puppeteer");
|
||||
|
||||
var srcHTML = "file:" + __dirname + "/pub/index.html";
|
||||
var destPDF = "./pub/cv-anders-englof-ytterstrom.pdf";
|
||||
|
||||
async function generatePDF() {
|
||||
const browser = await puppeteer.launch();
|
||||
const page = await browser.newPage();
|
||||
await page.goto(srcHTML, {
|
||||
waitUntil: "networkidle2",
|
||||
});
|
||||
await page.pdf({
|
||||
path: destPDF,
|
||||
});
|
||||
await browser.close();
|
||||
}
|
||||
|
||||
Metalsmith(__dirname)
|
||||
.source("./src")
|
||||
|
|
@ -31,4 +47,5 @@ Metalsmith(__dirname)
|
|||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
generatePDF();
|
||||
});
|
||||
|
|
|
|||
1334
package-lock.json
generated
1334
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -11,6 +11,7 @@
|
|||
"metalsmith-html-minifier": "^3.0.3",
|
||||
"metalsmith-layouts": "^1.4.1",
|
||||
"metalsmith-markdown-remarkable": "^1.0.2",
|
||||
"metalsmith-static": "0.0.5"
|
||||
"metalsmith-static": "0.0.5",
|
||||
"puppeteer": "^23.6.0"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue