{"record":{"id":"cf6fab2972024cca","repo":"microsoft/playwright","slug":"pdf-generation-is-only-supported-for-headless-chro","errorCode":null,"errorMessage":"PDF generation is only supported for Headless Chromium","messagePattern":"PDF generation is only supported for Headless Chromium","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/playwright-core/src/server/dispatchers/pageDispatcher.ts","lineNumber":339,"sourceCode":"  async mouseUp(params: channels.PageMouseUpParams, progress: Progress): Promise<void> {\n    await this._page.mouse.apiUp(progress, params);\n  }\n\n  async mouseClick(params: channels.PageMouseClickParams, progress: Progress): Promise<void> {\n    await this._page.mouse.apiClick(progress, params.x, params.y, params);\n  }\n\n  async mouseWheel(params: channels.PageMouseWheelParams, progress: Progress): Promise<void> {\n    await this._page.mouse.apiWheel(progress, params.deltaX, params.deltaY);\n  }\n\n  async touchscreenTap(params: channels.PageTouchscreenTapParams, progress: Progress): Promise<void> {\n    await this._page.touchscreen.apiTap(progress, params.x, params.y);\n  }\n\n  async pdf(params: channels.PagePdfParams, progress: Progress): Promise<channels.PagePdfResult> {\n    if (!this._page.pdf)\n      throw new Error('PDF generation is only supported for Headless Chromium');\n    const buffer = await progress.race(this._page.pdf(params));\n    return { pdf: buffer };\n  }\n\n  async requests(params: channels.PageRequestsParams, progress: Progress): Promise<channels.PageRequestsResult> {\n    // Send all future requests to the client, so that it can reliably receive all of them.\n    // Otherwise, if subscription is added in a different task from this call (either before or after),\n    // there is a chance for a duplicate or a lost request.\n    this._subscriptions.add('request');\n    return { requests: this._page.networkRequests().map(request => RequestDispatcher.from(this.parentScope(), request)) };\n  }\n\n  async bringToFront(params: channels.PageBringToFrontParams, progress: Progress): Promise<void> {\n    await this._page.bringToFront(progress);\n  }\n\n  async pickLocator(params: channels.PagePickLocatorParams, progress: Progress): Promise<channels.PagePickLocatorResult> {\n    const recorder = await progress.race(Recorder.forContext(this._page.browserContext, { omitCallTracking: true, hideToolbar: true }));","sourceCodeStart":321,"sourceCodeEnd":357,"githubUrl":"https://github.com/microsoft/playwright/blob/c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6/packages/playwright-core/src/server/dispatchers/pageDispatcher.ts#L321-L357","documentation":"page.pdf() is implemented only by the Chromium browser backend and only in headless mode. The dispatcher checks `this._page.pdf` (a delegate method that is undefined on Firefox/WebKit pages) and throws when it is absent. This is a hard backend-capability limitation, not a configuration toggle.","triggerScenarios":"Calling page.pdf() inside a test project configured for firefox or webkit; calling page.pdf() on Chromium launched with headless:false; running a shared page-interaction helper across all browser projects that unconditionally calls page.pdf().","commonSituations":"Cross-browser test suites with a single pdf spec file included in all projects; CI matrix that runs the same spec on chromium+firefox; switching a working Chromium suite to headed mode for debugging and forgetting pdf is called.","solutions":["Restrict page.pdf() calls to a chromium-only test project (configure projects in playwright.config to run the pdf spec only under chromium, headless).","Guard the call: `if (browserName === 'chromium') await page.pdf(...)`.","Ensure Chromium is launched headless (headless:true / 'new') — headed Chromium has no pdf backend either.","For Firefox/WebKit, render to an image (page.screenshot fullPage) as an alternative output."],"exampleFix":"// before\ntest('pdf', async ({ page }) => {\n  await page.pdf({ path: 'out.pdf' });\n});\n// after\ntest('pdf', async ({ page, browserName }) => {\n  test.skip(browserName !== 'chromium', 'PDF is Chromium-only');\n  await page.pdf({ path: 'out.pdf' });\n});","handlingStrategy":"validation","validationCode":"// Guard pdf() by browser type before calling.\nif (browserName === 'chromium') {\n  await page.pdf({ path: 'out.pdf' });\n}","typeGuard":"// Narrow to a pdf-capable page.\nfunction canPdf(browserName: string): boolean {\n  return browserName === 'chromium';\n}","tryCatchPattern":null,"preventionTips":["Put pdf specs in a chromium-only test project.","Keep Chromium headless for pdf runs — headed Chromium has no pdf backend.","Use test.skip(browserName !== 'chromium') at the top of pdf specs."],"tags":["pdf","chromium-only","browser-compat"],"backgroundTag":null,"analyzedSha":"c8fc3bf8d31542d59b4d4d9eaab1df93ff541dc6","analyzedAt":"2026-08-12T07:26:36.950Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}