Generated PDFs often leave large gaps or push a small section onto another page. pagefit checks the result and tries another layout when there is room to improve it.
My contribution
I defined the layout problem, readability limits and output checks. AI tools helped implement the tool.
Look at the finished pages
The tool converts Markdown, Typst or a web page to PDF, then measures how much of each page's text area is used.
Headers and footers are excluded. Including a page number at the bottom would make an almost empty page look full.
Stop before the text gets too small
I set limits on type size and margins. The tool tries slightly tighter settings and keeps them only if page count or fill improves.
If it cannot absorb an awkward page within those limits, that page stays.
The documented example
The repository records a study document changing from 26 pages to 17, with mean page fill rising from 72% to 96%. That result belongs to that document.
The code and instructions are public. The tool runs locally and reports what the layout loop changed.
Checking more document types
Long tables, quotations and illustrated pages need different checks. A useful next test set would compare page count with the actual reading experience, including broken tables and stranded headings.