Skip to content

Commit

Permalink
Merge pull request #166 from openearth/fix/pdf-export
Browse files Browse the repository at this point in the history
fix: possible fix for pdf export
  • Loading branch information
Arash217 authored Nov 29, 2022
2 parents 01294e4 + 306e9e8 commit 59c03d4
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/server/functions/export-to-pdf-from-markup.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const playwright = require('playwright-aws-lambda');
const chromium = require('chrome-aws-lambda');

function startTimer(id, description) {
const start = Date.now()
Expand All @@ -19,12 +19,18 @@ exports.handler = async event => {
try {
const endBrowserTimer = startTimer('launch', 'Launch Puppeteer')
if (!process.env.NETLIFY_DEV) {
browser = await playwright.launchChromium();
} else {
browser = await chromium.puppeteer.launch({
args: chromium.args,
defaultViewport: chromium.defaultViewport,
executablePath: await chromium.executablePath,
headless: chromium.headless,
ignoreHTTPSErrors: true,
});
}
if (process.env.NETLIFY_DEV) {
const puppeteer = await import('puppeteer')
browser = await puppeteer.default.launch({ headless: true })
}

timings.push(endBrowserTimer())

const endPageCreation = startTimer('newpage', 'Create New Page')
Expand Down

0 comments on commit 59c03d4

Please sign in to comment.