-
Notifications
You must be signed in to change notification settings - Fork 234
Open
Description
Feature Request
Add PDF generation support (page.pdf()) for extension mode. Currently, Playwright's page.pdf() works in standalone mode but fails in extension mode because the Chrome extension's CDP connection doesn't handle Page.printToPDF responses correctly (the base64-encoded PDF data is too large for the WebSocket message handling).
Use Case
Automating document workflows that need to save pages as PDFs:
- Archiving web pages
- Generating reports from dashboards
- Saving receipts/invoices
Proposed Solution
Intercept Page.printToPDF commands in the relay server:
- Forward the command to the extension
- Save the PDF data to a temp file (
~/.dev-browser/pdfs/{id}.pdf) - Return a download URL instead of raw base64 data
- Auto-cleanup temp files after 5 minutes
// Usage remains the same
const pdfBuffer = await page.pdf({ format: 'A4' });
// Relay intercepts and provides file-based transfer for large PDFsWorking Implementation
I have this working in my fork:
- https://github.com/parkerhancock/dev-browser
- Commit
8d618c0- Add PDF generation support
Features:
- Intercepts
Page.printToPDFin relay - Saves to
~/.dev-browser/pdfs/with UUID filename - Adds
/pdf/:idendpoint for downloads - Auto-cleanup after 5 minutes
- Includes test script at
scripts/test-pdf.ts
Happy to submit a PR if there's interest.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels