diff --git a/scripts/pdf.js b/scripts/pdf.js index 6bf30f5..b4918d8 100644 --- a/scripts/pdf.js +++ b/scripts/pdf.js @@ -101,7 +101,13 @@ async function generate() { page.setDefaultNavigationTimeout(120_000); page.setDefaultTimeout(120_000); - await page.goto(`file://${inputPath}`, { waitUntil: 'networkidle0', timeout: 120_000 }); + await page.goto(`file://${inputPath}`, { waitUntil: 'load', timeout: 120_000 }); + + // Wait until every has finished decoding (handles large local images) + await page.waitForFunction( + () => [...document.images].every(img => img.complete && img.naturalHeight > 0), + { timeout: 120_000 }, + ); // Write to temp file first so Ghostscript can read it await page.pdf({