[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"docs:adr\u002F0006-pages-that-grow-with-their-content":3},{"versions":4,"version":29,"nav":32,"path":118,"page":129},[5,10,13,17,20,23,26],{"name":6,"label":7,"prefix":8,"channel":9},"1.3","1.3.0 (latest)","","latest",{"name":11,"label":12,"prefix":11,"channel":11},"next","next (main)",{"name":14,"label":15,"prefix":14,"channel":16},"1.2","1.2.1","old",{"name":18,"label":19,"prefix":18,"channel":16},"1.1","1.1.1",{"name":21,"label":22,"prefix":21,"channel":16},"1.0","1.0.0",{"name":24,"label":25,"prefix":24,"channel":16},"0.2","0.2.0",{"name":27,"label":28,"prefix":27,"channel":16},"0.1","0.1.0",{"name":6,"label":7,"prefix":8,"channel":9,"base":30,"ref":31},"\u002Fdocs","v1.3.0",[33,37,40,43,46,49,52,55,58,61,64,68,71,74,77,80,83,86,89,93,96,99,102,105,108,111,114,117,120,123,126],{"slug":34,"title":35,"group":36},"index","Overview","Guide",{"slug":38,"title":39,"group":36},"getting-started","Getting started",{"slug":41,"title":42,"group":36},"php","PHP API",{"slug":44,"title":45,"group":36},"laravel","Laravel",{"slug":47,"title":48,"group":36},"resources","Resources",{"slug":50,"title":51,"group":36},"deployment","Deployment",{"slug":53,"title":54,"group":36},"troubleshooting","Troubleshooting",{"slug":56,"title":57,"group":36},"from-wkhtmltopdf","Coming from wkhtmltopdf",{"slug":59,"title":60,"group":36},"stability","Stability and upgrades",{"slug":62,"title":63,"group":36},"ai-assistants","Docs for AI assistants",{"slug":65,"title":66,"group":67},"css","CSS reference","Reference",{"slug":69,"title":70,"group":67},"paged-media","Paged media",{"slug":72,"title":73,"group":67},"fonts","Fonts",{"slug":75,"title":76,"group":67},"extensions","Extensions",{"slug":78,"title":79,"group":67},"compatibility","Compatibility",{"slug":81,"title":82,"group":67},"pdf","The PDF",{"slug":84,"title":85,"group":67},"cli","Command line",{"slug":87,"title":88,"group":67},"rust","Rust library",{"slug":90,"title":91,"group":92},"ffi","C library (experimental)","Internals",{"slug":94,"title":95,"group":92},"protocol","Worker protocol",{"slug":97,"title":98,"group":92},"releasing","Releasing",{"slug":100,"title":101,"group":92},"adr","Architecture decisions",{"slug":103,"title":104,"group":92,"parent":101},"adr\u002F0001-record-architecture-decisions","1. Record architecture decisions",{"slug":106,"title":107,"group":92,"parent":101},"adr\u002F0002-rust-and-fragmentation-in-layout","2. Rust core with fragmentation inside layout",{"slug":109,"title":110,"group":92,"parent":101},"adr\u002F0003-css-parsing-and-own-selector-matching","3. lightningcss for parsing, own selector matching and cascade",{"slug":112,"title":113,"group":92,"parent":101},"adr\u002F0004-extensions-only-where-css-has-no-way","4. Extensions only where CSS has no way",{"slug":115,"title":116,"group":92,"parent":101},"adr\u002F0005-public-api-and-deprecations","5. Public API, semantic versioning and deprecations",{"slug":118,"title":119,"group":92,"parent":101},"adr\u002F0006-pages-that-grow-with-their-content","6. Pages that grow with their content",{"slug":121,"title":122,"group":92,"parent":101},"adr\u002F0007-layers-for-screen-and-print","7. Layers for screen and print, and form fields as an option",{"slug":124,"title":125,"group":92,"parent":101},"adr\u002F0008-c-library-experimental","8. An experimental C library beside the worker",{"slug":127,"title":128,"group":92,"parent":101},"adr\u002F0009-resources-in-batches","9. Resources in batches, fetching stays with the caller",{"title":119,"seoTitle":130,"seoDescription":131,"html":132,"headings":133,"editUrl":144,"sourceUrl":145,"markdownUrl":146,"prev":147,"next":148},"Architecture decisions: 6. Pages that grow with their content · Fagus docs","Receipt printers print on rolls, 58mm or 80mm wide, and cut the paper where the document ends. A receipt is one page as long as its content: a page of a fixed height cuts it into pieces or leaves metres of blank paper.","\u003Ch1 id=\"6-pages-that-grow-with-their-content--fagus-page-height\">6. Pages that grow with their content: \u003Ccode>-fagus-page-height\u003C\u002Fcode>\u003C\u002Fh1>\n\u003Cul>\n\u003Cli>Status: proposed\u003C\u002Fli>\n\u003Cli>Date: 2026-11-19\u003C\u002Fli>\n\u003C\u002Ful>\n\u003Ch2 id=\"context\">Context\u003Ca class=\"f-doc-anchor\" href=\"#context\" aria-label=\"Link to this section\">#\u003C\u002Fa>\u003C\u002Fh2>\n\u003Cp>Receipt printers print on rolls, 58mm or 80mm wide, and cut the paper where the document ends. A receipt is one page as long as its content: a page of a fixed height cuts it into pieces or leaves metres of blank paper. CSS has no way to say this. \u003Ccode>size\u003C\u002Fcode> takes a width and a height; \u003Ccode>size: 80mm auto\u003C\u002Fcode> is invalid in CSS Paged Media 3 and dropped by Chrome, and Fagus drops it as well, with a \u003Ccode>css.invalid-value\u003C\u002Fcode> warning. A page box's \u003Ccode>height: auto\u003C\u002Fcode> in \u003Ccode>@page\u003C\u002Fcode> means the height that \u003Ccode>size\u003C\u002Fcode> leaves, not the content's.\u003C\u002Fp>\n\u003Cp>What people do today is render the document again and again with other heights in \u003Ccode>size\u003C\u002Fcode> until \u003Ccode>pages()\u003C\u002Fcode> is 1: a binary search that costs a dozen renders and still leaves the page a few millimetres too tall or too short.\u003C\u002Fp>\n\u003Ch2 id=\"decision\">Decision\u003Ca class=\"f-doc-anchor\" href=\"#decision\" aria-label=\"Link to this section\">#\u003C\u002Fa>\u003C\u002Fh2>\n\u003Cul>\n\u003Cli>A descriptor of \u003Ccode>@page\u003C\u002Fcode>, \u003Ccode>-fagus-page-height: auto | fit-content\u003C\u002Fcode>, as \u003Ca href=\"\u002Fdocs\u002Fadr\u002F0004-extensions-only-where-css-has-no-way\">ADR 4\u003C\u002Fa> requires. \u003Ccode>auto\u003C\u002Fcode>, the initial value, is the height \u003Ccode>size\u003C\u002Fcode> gives. With \u003Ccode>fit-content\u003C\u002Fcode>, the page is as tall as its content and its margins (and border and padding).\u003C\u002Fli>\n\u003Cli>Not \u003Ccode>size: 80mm auto\u003C\u002Fcode>: that value is invalid CSS, so a template written with it prints on A4 in Chrome and makes every other tool ignore the whole size. With the descriptor, \u003Ccode>size\u003C\u002Fcode> stays valid: browsers and other tools print the declared size, which is a usable preview, and Fagus grows the page from there. \u003Ccode>@supports (-fagus-page-height: fit-content)\u003C\u002Fcode> tells the two apart.\u003C\u002Fli>\n\u003Cli>The height of \u003Ccode>size\u003C\u002Fcode> is the least the page is tall. Viewport units, percentages of the page area and the containing block of fixed boxes need a definite page height before the content is laid out; the declared one is that height, so \u003Ccode>100vh\u003C\u002Fcode> and \u003Ccode>min-height: 100vh\u003C\u002Fcode> mean the same in Fagus as in the browser preview. A printer that needs a minimum length gets it from \u003Ccode>size\u003C\u002Fcode>; a document without one declares a small height, such as \u003Ccode>size: 80mm 40mm\u003C\u002Fcode>.\u003C\u002Fli>\n\u003Cli>The page is at most 14,400pt (200 inches, about 5 metres) tall, the largest page a PDF holds (ISO 32000-1, Annex C.2), less its bleed and the room for printer's marks. Content that does not fit goes on to a next page that grows in turn. Forced breaks still break: each page grows with the content it holds.\u003C\u002Fli>\n\u003Cli>The content's height is that of the root element's margin box, or of the monolithic content (lines, images) that reaches further. Absolutely positioned boxes do not make the page taller; fixed boxes are placed in the grown page area, so \u003Ccode>position: fixed; bottom: 0\u003C\u002Fcode> lands at the end of the page.\u003C\u002Fli>\n\u003Cli>The page is rounded up to whole points, as the PDF's page size is, so that rounding never cuts off content. The margin boxes, the page's background and border and the page counters follow the grown page as they follow any page.\u003C\u002Fli>\n\u003Cli>In vertical writing modes, where the content runs across the page and its height is the length of the lines, the descriptor is ignored.\u003C\u002Fli>\n\u003C\u002Ful>\n\u003Ch2 id=\"consequences\">Consequences\u003Ca class=\"f-doc-anchor\" href=\"#consequences\" aria-label=\"Link to this section\">#\u003C\u002Fa>\u003C\u002Fh2>\n\u003Cp>A receipt is one render: \u003Ccode>@page { size: 80mm 40mm; margin: 4mm; -fagus-page-height: fit-content }\u003C\u002Fcode>. Applications that searched for the height with \u003Ccode>pages()\u003C\u002Fcode> drop that loop.\u003C\u002Fp>\n\u003Cp>The page is laid out with room down to the tallest page, then cut to its content. Margin boxes are laid out after pagination already, so they need no second layout. Each further extension of \u003Ccode>@page\u003C\u002Fcode> follows the same pattern: a \u003Ccode>-fagus-\u003C\u002Fcode> descriptor next to the standard ones, a \u003Ccode>css.invalid-value\u003C\u002Fcode> diagnostic for values it does not take, and an entry in \u003Ccode>@supports\u003C\u002Fcode>.\u003C\u002Fp>\n",[134,138,141],{"id":135,"text":136,"level":137},"context","Context",2,{"id":139,"text":140,"level":137},"decision","Decision",{"id":142,"text":143,"level":137},"consequences","Consequences","https:\u002F\u002Fgithub.com\u002Fnforst\u002Ffagus\u002Fedit\u002Fmain\u002Fdocs\u002Fadr\u002F0006-pages-that-grow-with-their-content.md","https:\u002F\u002Fgithub.com\u002Fnforst\u002Ffagus\u002Fblob\u002Fv1.3.0\u002Fdocs\u002Fadr\u002F0006-pages-that-grow-with-their-content.md","\u002Fdocs\u002Fadr\u002F0006-pages-that-grow-with-their-content.md",{"slug":115,"title":116},{"slug":121,"title":122}]