> ## Documentation Index
> Fetch the complete documentation index at: https://docs.doczilla.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Generate a 4 × 6 shipping label

> Print a one-page label at actual size using CSS page dimensions.

Use CSS `@page` to set the physical paper size and `pdf.preferCSSPageSize` to ask Chrome to use it. This example makes a 4 × 6 inch label with a sample Code 39 barcode for order `1042`. For real shipments, use your carrier's barcode and label specifications.

## Render and print

Install the [Doczilla Node SDK](https://docs.doczilla.app/libraries/nodejs.md) with `npm install @doczilla/node`. Set `DOCZILLA_API_KEY` and run `node render-label.mjs` alongside the HTML file.

```javascript render-label.mjs theme={null}
import { readFile, writeFile } from 'node:fs/promises'
import Doczilla from '@doczilla/node'

const apiKey = process.env.DOCZILLA_API_KEY
if (!apiKey) {
  throw new Error('Set DOCZILLA_API_KEY')
}

const doczilla = new Doczilla(apiKey)

const html = await readFile(new URL('./label.html', import.meta.url), 'utf8')
const pdf = await doczilla.pdf.direct({
  page: { html },
  pdf: { preferCSSPageSize: true }
})

await writeFile('shipping-label.pdf', pdf)
```

## HTML

Save the HTML below as `label.html`. The barcode is inline SVG so the HTML can render without network requests. Print the resulting PDF at **Actual size** or **100%** on 4 × 6 inch stock.

> [accordion] Shipping label HTML
>
> <Snippet file="code-group/pdf-shipping-label-html.md" />

## Output

![Sample shipping label with sender, destination, and barcode for order 1042](https://mintcdn.com/doczilla/Teqhl5ABLAafgT50/images/examples/shipping-label.png?fit=max\&auto=format\&n=Teqhl5ABLAafgT50\&q=85\&s=54d0a5356b580308955126d6b5e63c7b)

[Open the sample shipping label PDF](https://docs.doczilla.app/images/examples/shipping-label.pdf)

See [PDF options](https://docs.doczilla.app/api-reference/pdf-options.md) for more control over print layout.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.