|
|
|
@ -8,7 +8,7 @@ let [
|
|
|
|
|
url,
|
|
|
|
|
title = '',
|
|
|
|
|
subtitle = '',
|
|
|
|
|
date = moment().format('YYYY-MM-DD')
|
|
|
|
|
date = moment().format('YYY-MM-DD')
|
|
|
|
|
] = process.argv.slice(2);
|
|
|
|
|
|
|
|
|
|
const path = './pdf';
|
|
|
|
@ -31,12 +31,8 @@ try{
|
|
|
|
|
|
|
|
|
|
// open page
|
|
|
|
|
const page = await browser.newPage();
|
|
|
|
|
page.setDefaultNavigationTimeout(0);
|
|
|
|
|
await page.goto(url);
|
|
|
|
|
await Promise.any([
|
|
|
|
|
page.mainFrame().waitForNavigation({waitUntil: 'networkidle0'}),
|
|
|
|
|
new Promise(resolve => setTimeout(resolve,2000))
|
|
|
|
|
]);
|
|
|
|
|
await page.goto(url, { waitUntil: 'networkidle0' });
|
|
|
|
|
console.log('page loaded');
|
|
|
|
|
|
|
|
|
|
// search for header and subheader in document
|
|
|
|
|
if (!title) title = await (await page.waitForSelector('h1')).evaluate(el => el.textContent);
|
|
|
|
@ -48,7 +44,7 @@ try{
|
|
|
|
|
// deactivate @print css and add custom css (for pretty code)
|
|
|
|
|
await page.emulateMediaType('screen');
|
|
|
|
|
await page.addStyleTag({content: `
|
|
|
|
|
body{
|
|
|
|
|
body {
|
|
|
|
|
text-shadow: none !important;
|
|
|
|
|
}
|
|
|
|
|
.hidden-print {
|
|
|
|
@ -79,7 +75,7 @@ try{
|
|
|
|
|
width: 100%;
|
|
|
|
|
padding: 2mm;
|
|
|
|
|
border-bottom: 1px #222 solid;
|
|
|
|
|
">${[title, subtitle].map(el=>el.trim()).filter(el=>!!el).join(' - ')}</div>
|
|
|
|
|
">${[title, subtitle].map(el=>el.trim()).filter(el=>!!el).join(' | ')}</div>
|
|
|
|
|
`,
|
|
|
|
|
footerTemplate: `
|
|
|
|
|
<div style="
|
|
|
|
|