Docs
PDF Options

PDF Options

Configure PDF document generation settings including orientation, scale, and margins.

Options for PDF format. These settings are passed in options.pdfOptions. PDF dimensions are derived from the viewport width and height.

Options

FieldTypeDefaultNotes
landscapebooleanfalseGenerate PDF in landscape orientation.
scalenumber (0.1-2)1Scale factor for rendering.
marginsPdfMarginsPage margins. See below.

Margins

Each margin property accepts CSS-style values:

FieldTypeNotes
topstringTop margin (e.g., "1cm", "0.5in", "20px").
rightstringRight margin.
bottomstringBottom margin.
leftstringLeft margin.

Supported Units

UnitExampleNotes
cm"1cm"Centimeters
mm"10mm"Millimeters
in"0.5in"Inches
px"20px"Pixels (at 96 DPI)

Scale Factor

The scale parameter adjusts the rendering size:

ScaleUse Case
0.5-0.9Fit more content on each page, smaller text
1.0Default, 1:1 rendering
1.1-2.0Larger text and elements, fewer pages

Scale values outside the 0.1-2 range will be rejected with a validation error.

Viewport and Page Size

PDF page dimensions are calculated from the viewport you specify:

  • Portrait: Page width = viewport width, page height = viewport height
  • Landscape: Page width = viewport height, page height = viewport width

Common viewport configurations for standard paper sizes:

Paper SizeViewport (Portrait)Viewport (Landscape)
A4794 × 11231123 × 794
Letter816 × 10561056 × 816
Legal816 × 13441344 × 816

Example Request

curl -s -X POST \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "urls": [
      "https://site.com/"
    ],
    "viewports": [
      {
        "width": 1280,
        "height": 800
      }
    ],
    "options": {
      "format": "pdf",
      "pdfOptions": {
        "landscape": false,
        "scale": 1,
        "margins": {
          "top": "1cm",
          "right": "1cm",
          "bottom": "1cm",
          "left": "1cm"
        }
      }
    }
  }' \
  "https://api.watchero.io/api/v1/snapshots"

Use Cases

Reports and Documentation

Generate archival PDFs of web content for compliance or record-keeping:

{
  "options": {
    "format": "pdf",
    "pdfOptions": {
      "margins": {
        "top": "2cm",
        "right": "2cm",
        "bottom": "2cm",
        "left": "2cm"
      }
    }
  }
}

For content designed for physical printing:

{
  "viewports": [{ "width": 794, "height": 1123 }],
  "options": {
    "format": "pdf",
    "pdfOptions": {
      "scale": 1,
      "margins": {
        "top": "0.5in",
        "right": "0.5in",
        "bottom": "0.5in",
        "left": "0.5in"
      }
    }
  }
}

We use cookies

We use cookies to ensure you get the best experience on our website. For more information on how we use cookies, please see our cookie policy.

By clicking Accept, you agree to our use of cookies.
Learn more.