diff --git a/packages/puppeteer-core/src/bidi/Page.ts b/packages/puppeteer-core/src/bidi/Page.ts index a6ef946d546..9e4808a3f50 100644 --- a/packages/puppeteer-core/src/bidi/Page.ts +++ b/packages/puppeteer-core/src/bidi/Page.ts @@ -321,6 +321,17 @@ export class BidiPage extends Page { preferCSSPageSize, } = parsePDFOptions(options, 'cm'); const pageRanges = ranges ? ranges.split(', ') : []; + + await firstValueFrom( + from( + this.mainFrame() + .isolatedRealm() + .evaluate(() => { + return document.fonts.ready; + }) + ).pipe(raceWith(timeout(ms))) + ); + const data = await firstValueFrom( from( this.#frame.browsingContext.print({ diff --git a/packages/puppeteer-core/src/cdp/Page.ts b/packages/puppeteer-core/src/cdp/Page.ts index b73761b77d8..d8158c82b4b 100644 --- a/packages/puppeteer-core/src/cdp/Page.ts +++ b/packages/puppeteer-core/src/cdp/Page.ts @@ -1133,6 +1133,16 @@ export class CdpPage extends Page { await this.#emulationManager.setTransparentBackgroundColor(); } + await firstValueFrom( + from( + this.mainFrame() + .isolatedRealm() + .evaluate(() => { + return document.fonts.ready; + }) + ).pipe(raceWith(timeout(ms))) + ); + const printCommandPromise = this.#primaryTargetClient.send( 'Page.printToPDF', {