ISO A series / A4
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.
The dimensions
One measurement in four units. Millimetres and inches are what a printer works in; points are what the PDF itself stores; pixels are only useful for checking a screen mock-up against the real thing.
- Millimetres: 210 x 297 mm
- Inches: 8.27 x 11.69 in
- Points: 595 x 842 pt
- CSS pixels: 794 x 1123 px at 96 dpi
Where the size comes from
The A series is built on one rule: halving a sheet across its long side gives the next size down with the same proportions. That only works if the ratio of the sides is the square root of two, and A0 is defined as the sheet of that shape with an area of exactly one square metre. A4 is A0 folded in half four times, which is where 210 by 297 comes from. Nothing about it is arbitrary, and it is why an A5 booklet imposes onto A4 with no scaling.
What gets printed at this size
- invoices, statements and anything a finance team will file
- contracts and reports, which is most of what an API like this renders
- letters, in every country that did not standardise on Letter
Margins that survive a real printer
18mm top and bottom, 16mm left and right is a safe starting point. Office laser printers cannot print within about 5mm of any edge and many cannot manage the bottom 10mm, so anything tighter than 10mm risks being clipped by the machine rather than by your layout. If the document will be hole punched, widen the left margin to 25mm and leave the right at 16mm.
The CSS
A4 is one of the six named formats the render API accepts, so it can be set in the request options or in the document's own CSS. Setting it in CSS keeps the size with the template, which is usually what you want.
@page {
size: A4 portrait;
margin: 18mm 16mm;
}
/* The browser default body margin is 8px and it stacks on top of the
page margin, which is why margins so often come out larger than set. */
html,
body {
margin: 0;
padding: 0;
}The render request
With a named format the size travels in the options and the CSS is optional.
{
"html": "<!doctype html>...",
"options": {
"format": "A4",
"margin": { "top": "18mm", "bottom": "18mm", "left": "16mm", "right": "16mm" }
}
}The mistake people make
Designing at 1123px because that is what A4 is at 96 pixels to the inch, then discovering the layout breaks when the same HTML is rendered at a different scale. Lay out in millimetres and let the page box do the conversion.
Frequently asked
What is A4 in pixels?
794 x 1123 px at 96 dpi, at the 96 pixels to the inch that CSS assumes. That number is useful for comparing a screen mock-up against the page, and useless for laying out the document: use 210 x 297 mm instead, because a page laid out in pixels shifts whenever the render scale changes.
Can I pass A4 as a format?
Yes. "A4" is one of the six format values the API accepts, alongside A4, A3, A5, Letter, Legal and Tabloid.
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.
A3 page size for PDF generation
A3 is two A4 sheets side by side, and it is what a document becomes when a table stops fitting.
A5 page size for PDF generation
A5 is half an A4 sheet, and the right size for a document that is short enough that A4 looks empty.
A6 page size for PDF generation
A6 is postcard size, a quarter of an A4 sheet, and the smallest ISO size that still holds a paragraph comfortably.
B5 page size for PDF generation
ISO B5 sits between A5 and A4, and it is the standard book block size across much of Europe and Asia.
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.
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.