chore: pdf generation now works in headed mode too

This commit is contained in:
Yury Semikhatsky 2024-12-05 09:08:41 -08:00
parent a7f2868594
commit 47e20ae9a3
3 changed files with 0 additions and 10 deletions

View file

@ -2762,10 +2762,6 @@ This method requires Playwright to be started in a headed mode, with a falsy [`o
Returns the PDF buffer. Returns the PDF buffer.
:::note
Generating a pdf is currently only supported in Chromium headless.
:::
`page.pdf()` generates a pdf of the page with `print` css media. To generate a pdf with `screen` media, call `page.pdf()` generates a pdf of the page with `print` css media. To generate a pdf with `screen` media, call
[`method: Page.emulateMedia`] before calling `page.pdf()`: [`method: Page.emulateMedia`] before calling `page.pdf()`:

View file

@ -3609,8 +3609,6 @@ export interface Page {
/** /**
* Returns the PDF buffer. * Returns the PDF buffer.
* *
* **NOTE** Generating a pdf is currently only supported in Chromium headless.
*
* `page.pdf()` generates a pdf of the page with `print` css media. To generate a pdf with `screen` media, call * `page.pdf()` generates a pdf of the page with `print` css media. To generate a pdf with `screen` media, call
* [page.emulateMedia([options])](https://playwright.dev/docs/api/class-page#page-emulate-media) before calling * [page.emulateMedia([options])](https://playwright.dev/docs/api/class-page#page-emulate-media) before calling
* `page.pdf()`: * `page.pdf()`:

View file

@ -18,8 +18,6 @@ import { browserTest as it, expect } from '../config/browserTest';
import fs from 'fs'; import fs from 'fs';
it('should be able to save file', async ({ contextFactory, headless, browserName }, testInfo) => { it('should be able to save file', async ({ contextFactory, headless, browserName }, testInfo) => {
it.skip(!headless || browserName !== 'chromium', 'Printing to pdf is currently only supported in headless chromium.');
const context = await contextFactory(); const context = await contextFactory();
const page = await context.newPage(); const page = await context.newPage();
const outputFile = testInfo.outputPath('output.pdf'); const outputFile = testInfo.outputPath('output.pdf');
@ -28,8 +26,6 @@ it('should be able to save file', async ({ contextFactory, headless, browserName
}); });
it('should be able to generate outline', async ({ contextFactory, server, headless, browserName }, testInfo) => { it('should be able to generate outline', async ({ contextFactory, server, headless, browserName }, testInfo) => {
it.skip(!headless || browserName !== 'chromium', 'Printing to pdf is currently only supported in headless chromium.');
// const context = await contextFactory();
const context = await contextFactory({ const context = await contextFactory({
baseURL: server.PREFIX, baseURL: server.PREFIX,
}); });