fix(pdf): stop logo from overlapping donor block on EOY receipts#2
Merged
Conversation
The header positioned the donor block based on text-line advance, so a 64pt logo extended past the "ISSUED TO" / "ISSUED" rows. Shrink the default logo slot to 48pt, constrain the org-name and receipt-label text widths to the column right of the logo, and explicitly advance doc.y past the logo bottom before the donor block. Add a sample receipt (PNG preview + downloadable PDF) to the README so the layout is visible at a glance. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR adjusts the PDF end-of-year receipt header layout to prevent a logo from overlapping the donor block, and adds a visible sample receipt (with a regeneration script) to make the rendered output easy to review.
Changes:
- Reduce the default PDF logo slot size (64pt → 48pt) and constrain header text to the non-logo column.
- Ensure the PDF cursor (
doc.y) advances past the bottom of the logo before rendering the donor block. - Add sample receipt assets + a generator script and link them from the README.
Reviewed changes
Copilot reviewed 3 out of 5 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
src/report/formats/pdf.ts |
Shrinks default logo size and adjusts header text positioning / doc.y advancement to avoid overlap. |
README.md |
Updates --logo-size default docs and embeds a sample receipt preview + download link. |
examples/gen-sample-receipt.mjs |
Adds a script to regenerate the sample receipt PDF using the built renderer. |
Comments suppressed due to low confidence (1)
src/report/formats/pdf.ts:185
- The header layout reserves
logoGutterand later advancesdoc.ybylogoSizewheneveropts.logoPathis set, even ifdoc.image(...)throws and the logo is not actually rendered. That leaves an unnecessary blank gutter and can push the donor block down despite a text-only header. Track whether the image render succeeded (or compute gutter/logoBottom inside thetry) and only apply the gutter anddoc.yadvance when the logo was drawn.
const logoSize = opts.logoSize ?? DEFAULT_LOGO_SIZE;
const logoGutter = opts.logoPath ? logoSize + 14 : 0;
if (opts.logoPath) {
try {
doc.image(opts.logoPath, left, headerY, { fit: [logoSize, logoSize] });
} catch {
/* fall through to text-only header */
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Align `PdfOptions.logoSize` JSDoc and `--logo-size` CLI help with the new 48pt default (was still documenting 64pt). - Switch README sample-receipt links to absolute github.com URLs so they resolve from the npm package page, which doesn't ship the `examples/` directory. - Note the `pnpm build` prerequisite in the gen-sample-receipt script header — it imports from `dist/`. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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
ISSUED TO/ISSUED) based on text-line advance, so a 64pt logo extended past the bottom of the header text and overlapped the row below. Shrunk the default logo slot to 48pt, constrained the org-name and receipt-label text widths to the column right of the logo, and explicitly advanceddoc.ypast the logo bottom before the donor block.examples/gen-sample-receipt.mjs.Preview
Test plan
pnpm test— 21/21 passingexamples/sample-receipt.pdf— logo no longer overlaps donor blockexamples/sample-receipt.pdfto sanity-check the new layout at print size🤖 Generated with Claude Code