Marks on the page / Fold and punch guides
Fold marks and punch hole guides that stay clear of the content
Faint marks at the page edge showing where a sheet will be folded or punched, so nothing important lands under a crease or a hole.
Why this block is harder than it looks
The marks themselves are trivial to draw. The real work is the clearance they imply: a two-punch filing margin takes about 20mm off one edge, a letter fold puts a crease across the page at one third and two thirds, and anything that lands on either is damaged or hidden. Most documents discover this after a run has been printed and filed. The marks are also easy to place wrong, because they are measured from the paper edge and it is tempting to measure them from the text block.
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.
- Reserve the clearance first and draw the marks second. The marks are a reminder of a decision, not the decision itself.
- Give a punched edge at least 20mm of margin with nothing in it, including page numbers and margin notes.
- Place fold marks as short rules at the very edge of the sheet, not as lines across the page, so they are unobtrusive and easy to align a fold to.
- Measure everything from the paper edge in millimetres, using fixed positioning, so a change to the text margins does not move the marks.
- Set them thin and grey. A fold mark that is as heavy as the content reads as a design element.
- Do not print them on a document that is not folded or punched. Stray marks near the corners look like a rendering fault.
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.
<div class="guides" aria-hidden="true">
<span class="fold" style="top: 99mm"></span>
<span class="fold" style="top: 198mm"></span>
<span class="punch" style="top: 68mm"></span>
<span class="punch" style="top: 148mm"></span>
</div>
<style>
@page {
size: A4;
/* filing margin on the left, with nothing in it */
margin: 22mm 20mm 26mm 34mm;
}
.guides span {
position: fixed; /* per page, measured from the sheet */
display: block;
}
.guides .fold {
left: 0;
width: 4mm;
border-top: 0.25pt solid #bbb; /* a short mark at the edge, not a line */
}
.guides .punch {
left: 12mm; /* the hole centre line */
width: 6mm;
height: 6mm;
margin-top: -3mm;
border: 0.25pt dashed #ccc;
border-radius: 50%;
}
</style>What breaks when it is built the obvious way
Drawing the marks without widening the margin. The document then shows exactly where the punch will destroy the text, which is honest and unhelpful. The clearance is the point and the mark is only a reminder of it.
How to prove it survived pagination
Print a page, punch it with a real punch and fold it for a real envelope. Nothing readable should be damaged or hidden. Then confirm the marks are in the same place on page one and page four, which they will not be if they were positioned in the flow.
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 business letter 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.
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.
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.
Printing an amount in words on a receipt, cheque or contract
The total written out as text as well as digits, which appears on cheques, receipts and contracts because a word cannot be altered with a pen the way a digit can.
Business letter, as a complete file
The whole document with this block already in place, ready to copy and change.
position: fixed 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.