mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
fix: wait for fonts before pdf printing (#12175)
This commit is contained in:
parent
f332284ffc
commit
59bffce972
@ -321,6 +321,17 @@ export class BidiPage extends Page {
|
|||||||
preferCSSPageSize,
|
preferCSSPageSize,
|
||||||
} = parsePDFOptions(options, 'cm');
|
} = parsePDFOptions(options, 'cm');
|
||||||
const pageRanges = ranges ? ranges.split(', ') : [];
|
const pageRanges = ranges ? ranges.split(', ') : [];
|
||||||
|
|
||||||
|
await firstValueFrom(
|
||||||
|
from(
|
||||||
|
this.mainFrame()
|
||||||
|
.isolatedRealm()
|
||||||
|
.evaluate(() => {
|
||||||
|
return document.fonts.ready;
|
||||||
|
})
|
||||||
|
).pipe(raceWith(timeout(ms)))
|
||||||
|
);
|
||||||
|
|
||||||
const data = await firstValueFrom(
|
const data = await firstValueFrom(
|
||||||
from(
|
from(
|
||||||
this.#frame.browsingContext.print({
|
this.#frame.browsingContext.print({
|
||||||
|
@ -1133,6 +1133,16 @@ export class CdpPage extends Page {
|
|||||||
await this.#emulationManager.setTransparentBackgroundColor();
|
await this.#emulationManager.setTransparentBackgroundColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await firstValueFrom(
|
||||||
|
from(
|
||||||
|
this.mainFrame()
|
||||||
|
.isolatedRealm()
|
||||||
|
.evaluate(() => {
|
||||||
|
return document.fonts.ready;
|
||||||
|
})
|
||||||
|
).pipe(raceWith(timeout(ms)))
|
||||||
|
);
|
||||||
|
|
||||||
const printCommandPromise = this.#primaryTargetClient.send(
|
const printCommandPromise = this.#primaryTargetClient.send(
|
||||||
'Page.printToPDF',
|
'Page.printToPDF',
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user