|
|
|
@ -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);
|
|
|
|
@ -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="
|
|
|
|
|