feat(page): add page.pdf() passthrough to CDP Page.printToPDF - #2819
Open
nagalikith wants to merge 2 commits into
Open
feat(page): add page.pdf() passthrough to CDP Page.printToPDF#2819nagalikith wants to merge 2 commits into
nagalikith wants to merge 2 commits into
Conversation
Add a Playwright-compatible pdf() across the protocol, extension, and TypeScript SDK: paper format/size with px/in/cm/mm lengths, margins, scale, header/footer templates, printBackground, preferCssPageSize, pageRanges, tagged/outline, omitBackground, and timeout. - protocol: register page.pdf schemas in the wire registry; spell the CSS-page-size option preferCssPageSize so the name survives the automatic camelCase <-> snake_case round-trip - extension: render via Page.printToPDF on the main-frame session with a cached Browser.getVersion headless probe (new headless reports plain Chrome in product, so check userAgent too) - sdk-ts: Page.pdf() returns bytes or writes options.path in Node; honor options.timeout for RPC response deadlines - sdk-go: add PdfLength scalar union so generated models compile; regenerate Python/Go protocol types - tests: Playwright->CDP mapping units, RPC routing case, and headless Chrome integration coverage
- format wins entirely over width/height (crPdf.ts semantics); without a format, letter defaults are overridden per axis - replicate Playwright's falsy-zero coercion for paper dimensions - replace the regex with suffix-based parsing accepting .5in / 1e2px / "+3cm" / "10 PX" / unitless pixels; non-CSS units like pt stay errors - lowercase options.format client-side so "A4" works past the lowercase-only wire enum; export PdfOptions from the package root
🦋 Changeset detectedLatest commit: 891fec6 The changes in this PR will be included in the next version bump. This PR includes changesets to release 12 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Contributor
|
This PR is from an external contributor and must be approved by a stagehand team member with write access before CI can run. |
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
first slice of #2744 — adds
page.pdf()as a thin passthrough to CDPPage.printToPDF, mirroring playwright's options (format, margins,scale, header/footer templates, printBackground, preferCssPageSize,
pageRanges, tagged/outline, omitBackground, timeout).
headless chrome only (CDP limitation). python/go get regenerated types
for now, sdk wrappers can come later.
tests: unit + integration against local headless chrome 152