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
Controls the dimensions of the generated PDF document
Usage
Using a preset:
Using custom dimensions:
Behavior
- When using a
preset, any providedwidthandheightvalues are ignored. - The
presetproperty takes precedence over custom dimensions if both are provided. - If neither
presetnor 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:-
Standardized documents: Use presets like
a4orletterfor documents that need to conform to standard paper sizes. - Custom publications: Create custom-sized documents for specialized publications like brochures, cards, or posters.
- Print-ready output: Ensure your PDFs match the exact dimensions required by your printing service.
Example
Creating a business card-sized PDF:prefer_css_page_size parameter in conjunction with size to control how content is scaled to fit the page.