# PDF Generation

> Generate production-ready PDFs with full control over margins, DPI, color modes, and page ranges

- **URL**: https://orshot.com/docs/pdf-generation

---

Orshot generates high-quality PDFs from your Studio templates — perfect for certificates, invoices, reports, tickets, and print-ready materials. Set `response.format` to `pdf` and use `pdfOptions` to control output quality and formatting.

## Quick Start

To generate a PDF, set the `response.format` to `"pdf"` in your API request:```javascript
const response = await fetch("https://api.orshot.com/v1/studio/render", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    Authorization: "Bearer <YOUR_API_KEY>",
  },
  body: JSON.stringify({
    templateId: "<YOUR_TEMPLATE_ID>",
    modifications: {
      recipient_name: "Jane Smith",
      certificate_title: "Course Completion Certificate",
      date: "March 25, 2026",
    },
    response: {
      format: "pdf",
      type: "url",
    },
  }),
});

const data = await response.json();
console.log(data.data.content); // PDF URL
```## How It Works

1. **Design a template** in [Orshot Studio](https://orshot.com/docs/orshot-studio) — the same template can render as an image or PDF
2. **Call the API** with `response.format: "pdf"` and any content overrides
3. **Receive your PDF** as a hosted URL or binary data

The same template that generates a PNG social post can generate a PDF document — just change the format.

## API Request Structure

| Field               | Type     | Required | Description                                                 |
| :------------------ | :------- | :------- | :---------------------------------------------------------- |
| `templateId`        | `string` | Yes      | Your Studio template ID                                     |
| `modifications`     | `object` | No       | Content overrides                                           |
| `response.format`   | `string` | Yes      | Set to `"pdf"`                                              |
| `response.type`     | `string` | No       | `"url"` or `"binary"`                                       |
| `response.scale`    | `number` | No       | Scale factor for output size                                |
| `response.fileName` | `string` | No       | Custom filename (without extension)                         |
| `pdfOptions`        | `object` | No       | PDF-specific settings (margin, DPI, color mode, page range) |

## PDF Options

Use the `pdfOptions` object to fine-tune your PDF output:```json
{
  "templateId": "<YOUR_TEMPLATE_ID>",
  "modifications": {
    "title": "Quarterly Report"
  },
  "response": {
    "format": "pdf",
    "type": "url"
  },
  "pdfOptions": {
    "margin": "20px",
    "dpi": 300,
    "colorMode": "rgb",
    "rangeFrom": 1,
    "rangeTo": 3
  }
}
```| Option      | Type     | Default | Description                                        |
| :---------- | :------- | :------ | :------------------------------------------------- |
| `margin`    | `string` | `"0px"` | Margin around the PDF content (CSS value)          |
| `dpi`       | `number` | `72`    | Resolution — use `300` for print quality           |
| `colorMode` | `string` | `"rgb"` | Color mode: `"rgb"` for screen, `"cmyk"` for print |
| `rangeFrom` | `number` | `null`  | Start page (for multi-page templates)              |
| `rangeTo`   | `number` | `null`  | End page (for multi-page templates)                |

## Response

The response structure is the same as image generation:```json
{
  "data": {
    "content": "https://storage.orshot.com/cloud/renders/pdfs/invoice-001.pdf",
    "renders": 1,
    "mimeType": "application/pdf"
  }
}
```## Common Use Cases

### Certificates```javascript
const response = await fetch("https://api.orshot.com/v1/studio/render", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    Authorization: "Bearer <YOUR_API_KEY>",
  },
  body: JSON.stringify({
    templateId: "<CERTIFICATE_TEMPLATE>",
    modifications: {
      recipient: "Alex Johnson",
      course: "Advanced JavaScript",
      date: "March 25, 2026",
      certificate_id: "CERT-2026-001",
    },
    response: {
      format: "pdf",
      type: "url",
      fileName: "certificate-alex-johnson",
    },
    pdfOptions: {
      dpi: 300,
    },
  }),
});
```### Invoices```javascript
await fetch("https://api.orshot.com/v1/studio/render", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    Authorization: "Bearer <YOUR_API_KEY>",
  },
  body: JSON.stringify({
    templateId: "<INVOICE_TEMPLATE>",
    modifications: {
      invoice_number: "INV-2026-0042",
      client_name: "Acme Corp",
      amount: "$2,450.00",
      due_date: "April 15, 2026",
      cta_button: "Pay Now",
      "cta_button.href": "https://pay.example.com/inv-0042",
    },
    response: {
      format: "pdf",
      type: "url",
    },
  }),
});
```### Event Tickets```javascript
await fetch("https://api.orshot.com/v1/studio/render", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    Authorization: "Bearer <YOUR_API_KEY>",
  },
  body: JSON.stringify({
    templateId: "<TICKET_TEMPLATE>",
    modifications: {
      event_name: "Tech Conference 2026",
      attendee: "Sarah Chen",
      seat: "Row A, Seat 14",
      qr_code:
        "https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=TICKET-001",
    },
    response: {
      format: "pdf",
      type: "url",
    },
  }),
});
```## Print-Ready PDFs

For professional printing, use high DPI and CMYK color mode:```json
{
  "response": {
    "format": "pdf",
    "type": "url"
  },
  "pdfOptions": {
    "dpi": 300,
    "colorMode": "cmyk",
    "margin": "0px"
  }
}
```## What's Next