Implement internal linking and two pass single page rendering for generated PDFs#13161
Open
benbowler wants to merge 2 commits into
Open
Implement internal linking and two pass single page rendering for generated PDFs#13161benbowler wants to merge 2 commits into
benbowler wants to merge 2 commits into
Conversation
📚 Storybook for f9b181e: 📦 Build files for f9b181e:
🎭 Playwright reports for f9b181e: |
zutigrm
reviewed
Jul 22, 2026
zutigrm
left a comment
Collaborator
There was a problem hiding this comment.
Thanks @benbowler looks good overall, I just have one question bellow
Comment on lines
+607
to
+622
| await pdf( | ||
| <DashboardReport | ||
| siteName={ reportSiteName } | ||
| siteURL={ referenceSiteURL || '' } | ||
| dashboardURL={ dashboardURL || '' } | ||
| dateRange={ { | ||
| startDate: dates.startDate, | ||
| endDate: dates.endDate, | ||
| { ...reportProps } | ||
| pageHeight={ PDF_MEASURE_PAGE_HEIGHT } | ||
| onRender={ ( layout ) => { | ||
| try { | ||
| measuredHeight = | ||
| measurePDFContentHeight( layout ); | ||
| sectionAnchors = | ||
| extractPDFSectionAnchors( layout ); | ||
| } catch ( error ) { | ||
| measureError = error; | ||
| } | ||
| } } | ||
| sections={ sections } | ||
| helpCenterURL="https://sitekit.withgoogle.com/support/?doc=get-support" | ||
| privacyPolicyURL="https://policies.google.com/privacy" | ||
| areas={ areas } | ||
| emailReportingSetupURL={ emailReportingSetupURL } | ||
| /> | ||
| ).toBlob(); |
Collaborator
There was a problem hiding this comment.
Before we had run blob render once (bellow), now we have 2 runs, and the timout for build is still armed using old 15s timeout
Is this still capable of running two blob renders under 15s, or should we reconsider increasing the timeout? In case running 2 of them add a bit of time, we might run into scenario where almost finished reort aborts due to the timeout etc. WDYT?
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.
Summary
Addresses issue:
Relevant technical choices
DocumentonRendercallback, then the final pass renders the page bounded to the measured height plus a fixed bottom padding.measurePDFContentHeightreads the undocumented_INTERNAL__LAYOUT__DATA_layout result and throws a clear error naming the expected property path when the shape is unrecognised, so a library upgrade fails the export cleanly instead of producing a broken PDF. Errors thrown insideonRenderare captured and rethrown after the render, since@react-pdfmay swallow exceptions raised in its render pipeline.<Link src="#section-{slug}">.@react-pdfregisters a named destination from a node's parent-relative top, so anidnested inside the report body lands the viewer a header height above the section. To anchor correctly, the measurement pass also extracts each section's absolute top (extractPDFSectionAnchors), and the final pass pins zero-size, absolutely positioned anchor views carrying the ids directly on the page, where relative and absolute tops coincide. Verified against the real library: destinations land exactly at each section's position.@react-pdfsizes awrap={false}page to its content and ignores the requested height, so the fixed bottom padding is applied through the page'spaddingBottom; this makes the rendered page height equal the computed measured height plus padding, with the explicitsizeheight kept as an upper bound.toBlob()now fires the document'sonRendercallback with a layout fixture mirroring the internal shape, so the two-pass flow is exercised in unit tests.PR Author Checklist
Do not alter or remove anything below. The following sections will be managed by moderators only.
Code Reviewer Checklist
Merge Reviewer Checklist