diff --git a/Dockerfile b/Dockerfile index 41b7b66..065bd17 100644 --- a/Dockerfile +++ b/Dockerfile @@ -29,6 +29,9 @@ RUN apt update \ libgbm1 \ libasound2 \ libatspi2.0-0 \ + # Needed by older Chromium only + libx11-xcb1 \ + libxshmfence1 \ && \ apt purge --auto-remove -y diff --git a/app/app.js b/app/app.js index 292a5a0..b79b0f2 100644 --- a/app/app.js +++ b/app/app.js @@ -35,8 +35,10 @@ async function main() { if (true) { const browser = await puppeteer.launch({ + dumpio: true, // You may see dbus errors headless: true, - executablePath: "./node_modules/puppeteer/.local-chromium/linux-938248/chrome-linux/chrome", + executablePath: "./node_modules/puppeteer/.local-chromium/linux-938248/chrome-linux/chrome", // puppeteer@~13.0.0 + //executablePath: "./node_modules/puppeteer/.local-chromium/linux-884014/chrome-linux/chrome", // puppeteer@~10.0.0, ~10.1.0 args: [ '--disable-gpu', '--disable-dev-shm-usage', @@ -57,7 +59,7 @@ async function main() { await page.goto('https://www.example.com', { waitUntil: 'networkidle2', }); - call = await page.screenshot({path: '/myapp/output/screenshot.png'}); + call = await page.screenshot({path: '/myapp/output/screenshot.png', format: 'a4', fullPage: true }); await page.close(); // Save a page as PDF @@ -65,7 +67,7 @@ async function main() { await page.goto('https://news.ycombinator.com', { waitUntil: 'networkidle2', }); - call = await page.pdf({ path: '/myapp/output/screenshot.pdf', format: 'a4' }); + call = await page.pdf({ path: '/myapp/output/screenshot.pdf', format: 'legal' }); await page.close(); // Save a page as PDF @@ -73,6 +75,13 @@ async function main() { await page.goto('file:///myapp/content/index.html', { waitUntil: 'networkidle2', }); + + // page.on("pageerror", function(err) { + // theTempValue = err.toString(); + // console.log("Page error: " + theTempValue); + // }); + + call = await page.screenshot({ path: '/myapp/output/screenshot2.png', format: 'a4', fullPage: true }); call = await page.pdf({ path: '/myapp/output/screenshot2.pdf', format: 'Legal' }); await page.close();