File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -71,7 +71,7 @@ export async function convertHtmlToPdf(
7171 maybeSetDefaultNavTimeout . setDefaultNavigationTimeout ?.( navigationTimeout ) ;
7272
7373 try {
74- await page . setContent ( finalHtml , { waitUntil : "networkidle2 " , timeout : navigationTimeout } ) ;
74+ await page . setContent ( finalHtml , { waitUntil : "networkidle0 " , timeout : navigationTimeout } ) ;
7575 } catch ( err ) {
7676 // If setContent times out, warn and continue: in CI some external requests
7777 // (fonts, images) may hang or be blocked and we still want to produce a PDF.
@@ -83,6 +83,15 @@ export async function convertHtmlToPdf(
8383 }
8484 }
8585
86+ // Wait for fonts to load before generating PDF
87+ try {
88+ // @ts -expect-error Suppressing type error for evaluate context
89+ // eslint-disable-next-line no-undef
90+ await page . evaluate ( ( ) => document . fonts . ready ) ;
91+ } catch ( err ) {
92+ console . warn ( "Warning: failed to wait for fonts - continuing anyway:" , err ) ;
93+ }
94+
8695 await page . pdf ( {
8796 path : outputFilePath ,
8897 format : "A4" ,
You can’t perform that action at this time.
0 commit comments