PDFPipe

Labels / 4 x 6 inch label

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.

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: 101.6 x 152.4 mm
  • Inches: 4 x 6 in
  • Points: 288 x 432 pt
  • CSS pixels: 384 x 576 px at 96 dpi

Where the size comes from

The size comes from the direct thermal printers that dominate shipping: a 4 inch print head is the widest common desktop unit, and 6 inches is long enough for an address block, a service barcode and a routing code without wasting media. Carrier label specifications are written to it, which is why it is not negotiable.

What gets printed at this size

  • carrier shipping labels, printed on a 4 inch thermal printer
  • warehouse pick and putaway labels
  • returns labels emailed to a customer to print at home

Margins that survive a real printer

3mm or less, and often zero. Thermal label stock is die cut to exactly 4 by 6 inches with no unprintable border, so the usable area is the whole label. Barcodes need a quiet zone instead: leave at least 6.35mm of blank space at each end of a linear barcode, because a scanner uses that silence to find where the code starts.

The CSS

4 x 6 inch label 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.

css
@page {
  size: 101.6mm 152.4mm;
  margin: 0;
}

body {
  margin: 0;
  /* Thermal printing is one bit per dot: there are no greys. Anything
     that is not solid black comes out as a dither pattern, which a
     scanner reads as noise. */
  color: #000;
  background: #fff;
}

.barcode {
  /* The quiet zone is not decoration. Without it the scan fails. */
  padding: 0 7mm;
}

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.

json
{
  "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

Rendering the label at A4 and expecting the printer driver to scale it down. Scaling a barcode changes the ratio of bar to space by a fraction of a millimetre, and that is enough to push it outside the tolerance a scanner accepts. Render at the final size.

Frequently asked

What is 4 x 6 inch label in pixels?

384 x 576 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 101.6 x 152.4 mm instead, because a page laid out in pixels shifts whenever the render scale changes.

Can I pass 4 x 6 inch label as a format?

No. The API accepts six named formats: A4, A3, A5, Letter, Legal and Tabloid. 4 x 6 inch label 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.

Paste the CSS below into the playground and see the page box it produces.