Skip to content

Commit

Permalink
Merge pull request #165 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 1d9b582 + ddd2adc commit 01294e4
Show file tree
Hide file tree
Showing 3 changed files with 158 additions and 10 deletions.
152 changes: 152 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
"normalize.css": "8.0.0",
"nuxt": "1.4.2",
"nuxt-i18n": "^5.12.7",
"playwright-aws-lambda": "^0.9.0",
"playwright-core": "^1.28.1",
"portal-vue": "^2.1.6",
"puppeteer-core": "^2.0.0",
"query-string": "6.1.0",
Expand Down
14 changes: 4 additions & 10 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 chromium = require('chrome-aws-lambda');
const playwright = require('playwright-aws-lambda');

function startTimer(id, description) {
const start = Date.now()
Expand All @@ -19,18 +19,12 @@ exports.handler = async event => {
try {
const endBrowserTimer = startTimer('launch', 'Launch Puppeteer')
if (!process.env.NETLIFY_DEV) {
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) {
browser = await playwright.launchChromium();
} else {
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 01294e4

Please sign in to comment.