Marks on the page / Landscape page in a portrait document
One landscape page inside an otherwise portrait document
A single page turned on its side to hold a wide table or drawing, inside a document that is otherwise portrait.
Why this block is harder than it looks
Changing orientation mid-document is a named-page problem, and the part people get wrong is that a page rule is not something you can switch on and off in the flow: it is attached to an element through the page property, and everything about that page including its margins and margin boxes comes from the named rule rather than being inherited. The second question is which way to turn it. A landscape page in a bound document should read with the head to the left, so the reader turns the document clockwise, and getting that backwards means every reader turns the wrong way once.
The decisions that make it work
Reasons rather than a description of the code. Each of these is a choice that has a wrong answer, and the wrong answer is usually the default.
- Define a named page with size: A4 landscape and apply it to the element, rather than trying to change orientation with a transform.
- Repeat the margin box content in the landscape rule. Nothing is inherited from the unnamed page, so a folio you defined once is absent here unless you define it again.
- Force a break before and after, so the landscape leaf is exactly one page and the portrait flow resumes cleanly.
- Turn the content so the head is at the left edge of the portrait sheet, which is the binding convention, and check it against a printed and bound copy rather than reasoning about it.
- Keep the folio in the same physical corner of the sheet as on the portrait pages if the document is bound, so a reader flicking through sees the numbers in one place.
- Do not use it for a table that could have been made to fit. A single turned page costs the reader more than a slightly smaller type size.
The fragment
Markup and the CSS it needs, and nothing else. It expects a document that already has a page rule and a base stylesheet, so paste it into one rather than opening it on its own.
<section class="wide-table">
<h2>Schedule of defects</h2>
<table> ... a genuinely wide table ... </table>
</section>
<style>
@page { size: A4; margin: 22mm 20mm 26mm;
@bottom-right { content: counter(page); font-size: 8pt; } }
@page wide {
size: A4 landscape;
margin: 20mm 22mm;
/* nothing is inherited: the folio has to be declared again */
@bottom-right { content: counter(page); font-size: 8pt; }
}
.wide-table {
page: wide;
break-before: page;
break-after: page; /* exactly one leaf, then portrait resumes */
}
</style>What breaks when it is built the obvious way
Rotating the content with a transform instead of using a landscape page. The page stays portrait, so the text block is still the portrait width and the rotated content overflows it, and selecting or extracting the text gives you a rotated mess rather than a table.
How to prove it survived pagination
Render, print double sided, and bind or staple the result. Turning the document to read the landscape page should be one natural movement in the same direction every time. Then confirm the folio is present on the landscape page and in the expected corner of the sheet.
Where it sits in a finished document
This page is one block. The document it belongs to has a page rule, a base stylesheet, a header and everything else around it, and repeating all of that here would make thirty pages that say the same thing. The multi-page report template is a complete file with this block already in it, so take that and change the fragment rather than assembling one from parts. The property doing most of the work here is covered on its own page, with the support caveats that belong there rather than here.
Frequently asked
Will this fragment work on its own?
Not as a whole document. It has no page rule, no margins and no base type, because those belong to the document rather than to the block, and duplicating them in every fragment would mean thirty copies to keep in step. Paste it into a template that already has them.
Why does it look right in a browser and wrong in the PDF?
Because a browser window is one continuous surface and a document is a stack of fixed rectangles. Nothing in a scrolling view exercises a page boundary, so every break rule in the fragment is inert until the content is paginated. Render the real thing with enough content to cross two or three boundaries, then look.
Do I need a special option on the render request for this?
No. Everything on this page is CSS and markup, which is your side of the boundary. What the render has to give you is a real page size with real margins, and after that the layout is decided by the stylesheet.
Other parts of a document
The blocks that sit next to this one, and one from the next group along so you are not sealed inside a single kind of problem.
Two column body text that balances and does not strand a heading
Running text set in two columns for the length of a document or a section, rather than for a short list.
A full page image that reaches the paper edge on all four sides
An image occupying an entire page with no margin, used as a divider, a cover or a plate in a document that will be trimmed.
Ruled lines sized for handwriting on a printed form
An open area of ruled lines for somebody to write on, on a form completed by hand.
Listing serial numbers under a line without breaking the row
Identifiers attached to a delivered item, printed under the line they belong to, where one line can carry one identifier or four hundred.
Multi-page report, as a complete file
The whole document with this block already in place, ready to copy and change.
page (named pages) in paged output
The property carrying the weight here, with its real support status.
Every part of a document
The full list, grouped by the kind of problem the block poses.
Paste the fragment into the playground inside a page rule and see what it does at a real page size. That is the only way any of this gets confirmed.