Skip to content

Print a poster whole on one page when no width fits its content - #177

Merged
markbac merged 1 commit into
mainfrom
claude/poster-fit-overflow
Oct 23, 2026
Merged

markbac merged 1 commit into
mainfrom
claude/poster-fit-overflow

Conversation

@markbac

@markbac markbac commented Oct 23, 2026

Copy link
Copy Markdown
Owner

Problem

A poster's page script widens its layout until the content fits the paper's proportions, up to 4000 px. Pictures as wide as their column grow with the page, so a poster with several large pictures fits at no width.

The script then kept 4000 px, gave the poster the paper's height and let the content overflow:

  • Printed from Chrome, the rest went onto a second page.
  • py-doc poster --pdf prints page 1 only, so the bottom of the poster, footer included, was silently cut off.

Change

src/py_doc/poster.py, the page script:

  • When no width fits, it takes the width whose content is least tall for that width, so the poster prints as large as it can.
  • The poster is as tall as its content, so nothing is cut off.
  • On beforeprint, the poster is scaled to fit the page and centred, with margins at the sides. This covers Chrome's print dialogue and --pdf alike.
  • It marks the poster data-squeezed and warns in the browser console.
  • Posters that fit are unchanged: their print zoom and margin are what they were.

The posters guide and the writing guide say what happens and what to do about it. The new sentences keep within the Vale sentence limit.

Testing

  • New browser test: a picture too tall to fit at any width. It checks that the poster holds all its content, prints on one page and is centred. It fails before the change and passes after.
  • Full suite: 1331 passed, 43 skipped. ruff check and ruff format --check are clean.
  • Real poster: an A1 landscape poster with seven screenshots, which lost its footer before, now prints whole on one page.
  • --pdf itself was not run, because it needs the tool container. poster_pdf.js takes the same steps the test does: print media, beforeprint, then the PDF.

Not done

The warning shows only in the browser console. Reporting it in the terminal during --pdf would mean passing output back from the container.


Generated by Claude Code

The page script widens a poster until its content fits the paper, up to
4000 px. Pictures as wide as their column grow with the page, so a
poster with several large ones fits at no width. It was then given the
paper's height at 4000 px and its content overflowed: Chrome printed the
rest on a second page, and --pdf, which prints page 1 only, cut it off.

Now the script takes the width whose content is least tall for it, lets
the poster be as tall as its content, and on beforeprint scales it to
fit the page, centred, with margins at the sides. It marks the poster
data-squeezed and warns in the console. Posters that fit are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QshqEpLDivU1Yp8ZGZGsEE
@markbac
markbac merged commit b8d3711 into main Oct 23, 2026
7 checks passed
@markbac
markbac deleted the claude/poster-fit-overflow branch October 23, 2026 14:57
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