Skip to content

Commit

Permalink
fix: increasing screenshot quality in puppeteer
Browse files Browse the repository at this point in the history
  • Loading branch information
davodm committed Oct 23, 2023
1 parent 434f21b commit 6000901
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/html.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ async function createImageFromTemplate(templateName, data, outputFileName) {
const template = await renderTemplate(templateName, data, true);
// Open browser
const browser = await puppeteerCore.launch({
//executablePath: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
executablePath: await chromium.executablePath(),
headless: chromium.headless,
args: [
Expand All @@ -29,6 +30,8 @@ async function createImageFromTemplate(templateName, data, outputFileName) {
],
});
const page = await browser.newPage();
// Set viewport to increase quality
await page.setViewport({width: 1024, height: 1024, deviceScaleFactor: 3});
// Set HTML Content
await page.setContent(template);
// Wait for any asynchronous operations to complete
Expand Down

0 comments on commit 6000901

Please sign in to comment.