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

# Page size

> Set the dimensions of your PDF output using standard presets or custom sizes

The `size` parameter allows you to control the dimensions of the generated PDF document.

## Overview

When rendering a PDF, you can specify the page size either by using standard paper size presets (like A4, Letter) or by defining custom dimensions with a specific unit of measurement.

## Parameter details

<ResponseField name="size" type="object" default={{"preset": "a4"}}>
  Controls the dimensions of the generated PDF document

  <Expandable title="Properties">
    <ResponseField name="preset" type="enum<string>">
      Standard paper size preset (e.g., a4, letter)
    </ResponseField>

    <ResponseField name="width" type="number">
      Custom width (when not using preset)
    </ResponseField>

    <ResponseField name="height" type="number">
      Custom height (when not using preset)
    </ResponseField>

    <ResponseField name="unit" type="enum<string>" default="mm">
      Unit for width/height (`mm`, `cm`, `in`, `px`)
    </ResponseField>
  </Expandable>
</ResponseField>

## Usage

### Using a preset:

```javascript theme={null}
{
  "parts": "https://example.com",
  "size": {
    "preset": "a4"
  }
}
```

### Using custom dimensions:

```javascript theme={null}
{
  "parts": "https://example.com",
  "size": {
    "width": 210,
    "height": 297,
    "unit": "mm"
  }
}
```

## Behavior

* When using a `preset`, any provided `width` and `height` values are ignored.
* The `preset` property takes precedence over custom dimensions if both are provided.
* If neither `preset` nor custom dimensions are specified, the default A4 size is used.

## Available presets

The following standard paper size presets are available:

| Preset  | Size (mm)  | Size (inches) |
| ------- | ---------- | ------------- |
| a0      | 841 × 1189 | 33.1 × 46.8   |
| a1      | 594 × 841  | 23.4 × 33.1   |
| a2      | 420 × 594  | 16.5 × 23.4   |
| a3      | 297 × 420  | 11.7 × 16.5   |
| a4      | 210 × 297  | 8.3 × 11.7    |
| a5      | 148 × 210  | 5.8 × 8.3     |
| a6      | 105 × 148  | 4.1 × 5.8     |
| a7      | 74 × 105   | 2.9 × 4.1     |
| a8      | 52 × 74    | 2.0 × 2.9     |
| a9      | 37 × 52    | 1.5 × 2.0     |
| a10     | 26 × 37    | 1.0 × 1.5     |
| letter  | 216 × 279  | 8.5 × 11.0    |
| legal   | 216 × 356  | 8.5 × 14.0    |
| tabloid | 279 × 432  | 11.0 × 17.0   |
| ledger  | 432 × 279  | 17.0 × 11.0   |

## Use cases

This parameter is particularly useful for:

1. **Standardized documents**: Use presets like `a4` or `letter` for documents that need to conform to standard paper sizes.

2. **Custom publications**: Create custom-sized documents for specialized publications like brochures, cards, or posters.

3. **Print-ready output**: Ensure your PDFs match the exact dimensions required by your printing service.

## Example

Creating a business card-sized PDF:

```javascript theme={null}
{
  "parts": "<div style='text-align: center;'><h2>John Doe</h2><p>Software Engineer</p><p>john@example.com</p></div>",
  "size": {
    "width": 3.5,
    "height": 2,
    "unit": "in"
  }
}
```

Note: For responsive web content, you may want to use the `prefer_css_page_size` parameter in conjunction with `size` to control how content is scaled to fit the page.
