Receipt rolls / 58mm receipt roll
58mm thermal receipt PDF size and page setup
The 58mm roll is the narrow receipt used by mobile and handheld printers, with a printable width of roughly 48mm.
Where the size comes from
58mm exists because the printer has to fit in a hand or a belt holster. At 203 dots per inch the common head is 384 dots, which is 48.1mm, so a full third of the media width is feed margin. It is the tightest commonly used page in this list and the one where layout decisions are forced rather than chosen.
What gets printed at this size
- mobile card readers and handheld point of sale
- taxi, delivery and field service receipts
- parking and vending tickets
Margins that survive a real printer
2mm left and right for a 54mm page box, and design to 48mm of content. At 48mm a monospace face at 9pt fits about 32 characters, which is the number that actually governs the layout: an item name and a price on the same line means the name gets around 22 characters and no more.
The CSS
58mm receipt roll is not one of the six named formats the API accepts, so the size has to come from the document. Declare it in the page box and set prefer_css_page_size in the request.
@page {
size: 58mm 200mm;
margin: 0 2mm;
}
body {
margin: 0;
font-family: "IBM Plex Mono", "Courier New", monospace;
font-size: 9pt;
color: #000;
}
.line {
display: flex;
justify-content: space-between;
gap: 2mm;
}
.line .name {
/* 32 characters total, and the price needs ten of them. */
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}The render request
With a custom size the options carry no format at all: the one flag tells the renderer to use the page box the document declares.
{
"html": "<!doctype html>...",
"options": {
// No named format. The page box in the document's own CSS is the
// size, and this flag is what tells the renderer to use it.
"prefer_css_page_size": true
}
}The mistake people make
Porting an 80mm receipt template by changing the page size. The content width drops by a third, every item line wraps, and a receipt that was twelve lines becomes twenty-five. The 58mm layout has to drop columns, not shrink them.
Frequently asked
How do I set a size the API has no name for?
Declare the rectangle in the document's own CSS page box, in millimetres or inches, and set prefer_css_page_size on the request. Do not also pass a named format: the two disagree and you should not have to know which wins.
Can I pass 58mm receipt roll as a format?
No. The API accepts six named formats: A4, A3, A5, Letter, Legal and Tabloid. 58mm receipt roll is reached through the document's page box with prefer_css_page_size set, which is a supported path and not a workaround.
Does landscape need a different page size?
No. Landscape is the same rectangle turned, so it is set as an orientation rather than as swapped dimensions. Writing the width and height the other way round produces the same page and makes the intent harder to read later.
Other page sizes
Sizes that come up in the same conversation, and one from each of the other families.
80mm thermal receipt PDF size
The 80mm roll is the standard point-of-sale receipt: 80 millimetres of paper, a printable width of about 72mm, and a length that depends on the order.
A4 page size for PDF generation
A4 is the default page for business documents everywhere except North America, and the default this API uses when no format is given.
US Letter page size for PDF generation
Letter is 8.5 by 11 inches and it is the default page in the United States, Canada, Mexico, Chile and the Philippines.
4x6 shipping label PDF size
The 4 by 6 inch label is the standard thermal shipping label accepted by every major carrier, and the most common non-paper page size an API renders.
Business card PDF size and bleed
85.6 by 53.98 millimetres is the ID-1 rectangle: the size of a bank card, and the business card standard across most of the world.
DL envelope PDF size and window position
DL is 220 by 110 millimetres, the standard business envelope in Europe, and it takes an A4 sheet folded in three.
30-per-sheet address label PDF template
Thirty 2.625 by 1 inch labels in a 3 by 10 grid on a Letter sheet, which is the most common laser address label stock in North America.
Every page size, with dimensions
The full list, grouped by what the size is for.
Paste the CSS below into the playground and see the page box it produces.