Numbers, tables and totals / Dimensions and weight block
A dimensions and weight block that lines up across units
Length, width, height, gross and net weight and volume, printed for a package or a consignment, usually in two systems of units at once.
Why this block is harder than it looks
The values are short and the trouble is the units. Dimensions are three numbers that belong together and are usually printed as one string, which means they cannot be aligned as a column when there are twenty packages. Weights come in a gross and a net that must be visibly distinguishable, because confusing them changes what a carrier charges. And where the document crosses a border, both systems of units appear, which doubles everything and introduces the same alignment problem the multi-currency total has.
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.
- Put each dimension in its own cell rather than concatenating them into a string, so the lengths align on their digits down a column of packages.
- Print the unit once, in the column header, not on every value. Twenty repetitions of the same unit is twenty pieces of noise.
- Where both systems appear, give the second one its own column set at a smaller size, rather than putting it in brackets after the first. Bracketed alternates destroy the column.
- Keep gross and net weight adjacent and labelled in full. Abbreviating them to G and N saves four characters and costs a query with the carrier.
- Round consistently and state the precision in the header. A column mixing 1.2 and 1.25 reads as inconsistent data even when both are correct.
- Total the column if there is more than one package, and keep the total with the table using break-inside: avoid on the wrapper.
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.
<table class="dims">
<thead>
<tr>
<th>Package</th>
<th class="n" colspan="3">Dimensions (cm)</th>
<th class="n">Net (kg)</th>
<th class="n">Gross (kg)</th>
</tr>
</thead>
<tbody>
<tr>
<td>1 of 3</td>
<td class="n">120.0</td><td class="n">80.0</td><td class="n">96.5</td>
<td class="n">184.0</td><td class="n">201.4</td>
</tr>
</tbody>
</table>
<style>
.dims { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 9pt; }
.dims th, .dims td { padding: 3pt 4pt; }
.dims .n {
text-align: right;
white-space: nowrap;
font-variant-numeric: tabular-nums;
}
.dims thead th { border-bottom: 0.5pt solid currentColor; font-weight: 600; }
/* the three dimension cells read as one measurement */
.dims td:nth-child(2), .dims td:nth-child(3) { border-right: 0.3pt solid #ddd; }
</style>What breaks when it is built the obvious way
Printing dimensions as a single string like 120 x 80 x 96.5 cm. It is compact, it is readable for one package, and for twenty it is a column of ragged text that nobody can scan or total. Split it into cells and the same information becomes checkable.
How to prove it survived pagination
Render twenty packages with a mix of two-digit and three-digit dimensions and one value with a decimal. Every column edge should be straight. Then confirm the gross column is never lower than the net column, which is a data check the layout will not catch but a reader will.
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 packing slip 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.
A meter reading table showing previous, current and consumption
Previous reading, current reading, the difference and the charge, printed for one or several meters on a utility-style bill.
A risk matrix that survives being printed in black and white
A likelihood by consequence grid with cells scored and coloured, used in method statements, assessments and permits.
A time log where start, end and duration are all checkable
Rows of start time, end time and elapsed duration, with a total, used on timesheets, service reports and anything billed by the hour.
A delivery details block with dates, carrier and terms
Dispatch date, expected arrival, carrier, consignment reference and delivery terms, gathered into one block near the top of a despatch document.
Packing slip, as a complete file
The whole document with this block already in place, ready to copy and change.
font-variant-numeric 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.