Everything else / Custom dimensions
Set a custom PDF page size in millimetres
Any page size at all is reachable by declaring it in the document's own CSS and asking the renderer to honour that page box rather than a named format.
Where the size comes from
The render API accepts six named formats, which covers the paper most documents are printed on and nothing else. Everything with a die, a roll or a holder behind it needs an explicit rectangle, and the CSS page box is where that rectangle belongs: it travels with the document, so the size cannot be lost between the template and the call that renders it.
What gets printed at this size
- any label, ticket, tag, badge or card stock with a fixed die
- roll media, where the width is fixed and the length is not
- regional paper sizes outside the ISO and North American series
- wristbands, luggage tags and other narrow formats
Margins that survive a real printer
Whatever the stock allows, and the number to find out is the unprintable border, not the sheet size. Die cut label stock usually has none, so zero is correct. Sheet paper always has one, and below about 5mm you are inside it on most desktop printers.
The CSS
Custom dimensions 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 {
/* Width first, then height, in a real print unit. Millimetres and
inches are safe; pixels are not, because they convert at 96 to the
inch and any rounding shows up as a hairline. */
size: 63mm 88mm;
margin: 3mm;
}
html,
body {
margin: 0;
padding: 0;
}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
Declaring the size in CSS and also passing a named format in the render options. The two disagree, and which one wins is not something you should have to know. Set prefer_css_page_size and leave the format alone.
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 Custom dimensions as a format?
No. The API accepts six named formats: A4, A3, A5, Letter, Legal and Tabloid. Custom dimensions 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.
US check PDF size and MICR placement
A US business check is 8.5 by 3.5 inches, and almost every constraint on it comes from the machine-readable line along the bottom.
16:9 slide page size for PDF export
A 16:9 slide is 338.67 by 190.5 millimetres, which is 1280 by 720 pixels at 96 to the inch, and it is the page to use when the PDF will be projected rather than printed.
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.
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.
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.
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.