Skip to content

fix(pdf): stop logo from overlapping donor block on EOY receipts#2

Merged
EssentialsDev merged 2 commits into
mainfrom
fix/readme-logo-sizing
May 21, 2026
Merged

fix(pdf): stop logo from overlapping donor block on EOY receipts#2
EssentialsDev merged 2 commits into
mainfrom
fix/readme-logo-sizing

Conversation

@EssentialsDev
Copy link
Copy Markdown
Owner

Summary

  • The EOY receipt header was positioning the donor block (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 advanced doc.y past the logo bottom before the donor block.
  • Added a sample receipt to the README (PNG preview inline + downloadable PDF) so the rendered layout is visible without cloning the repo. Regeneration script lives at examples/gen-sample-receipt.mjs.

Preview

sample

Test plan

  • pnpm test — 21/21 passing
  • Visually verified the regenerated examples/sample-receipt.pdf — logo no longer overlaps donor block
  • Reviewer: open examples/sample-receipt.pdf to sanity-check the new layout at print size

🤖 Generated with Claude Code

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>
Copilot AI review requested due to automatic review settings May 20, 2026 22:05
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 logoGutter and later advances doc.y by logoSize whenever opts.logoPath is set, even if doc.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 the try) and only apply the gutter and doc.y advance 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.

Comment thread src/report/formats/pdf.ts
Comment thread README.md Outdated
Comment thread examples/gen-sample-receipt.mjs
- 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>
@EssentialsDev EssentialsDev merged commit a374edd into main May 21, 2026
2 checks passed
@EssentialsDev EssentialsDev deleted the fix/readme-logo-sizing branch May 21, 2026 18:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants