---
title: "Render HTML to PDF"
method: POST
path: "/html/to-pdf"
tags: ["HTML"]
---

# Render HTML to PDF

`POST /html/to-pdf`

## Request

- Base URL: `https://api.filegraph.ai` (the document declares no server; this is the origin it was published from)
- URL: `https://api.filegraph.ai/html/to-pdf`
- Auth: API key in header `X-API-Key`

Render an HTML document to PDF format.

Uses a headless browser to render the HTML with:
- CSS styling
- Images
- JavaScript execution (optional)

## Options
- **page_size**: Paper size (A4, Letter, etc.)
- **landscape**: Landscape orientation
- **print_background**: Include background colors/images

## Query parameters

- `page_size` string
- `landscape` boolean
- `print_background` boolean

## Response `200`

Successful Response

- FileResponse: Response containing a file.
  - `filename` string, required: Output filename
  - `content_type` string, required: MIME type of the file
  - `size_bytes` integer, required: File size in bytes
  - `content_base64` string, required: Base64-encoded file content

## Other responses

- `422`: Validation Error

---

[API](https://skmtc.dev/filegraph/apis/docconvert-api.md) · [All operations](https://skmtc.dev/filegraph/apis/docconvert-api/llms.txt) · [OpenAPI document](https://skmtc.dev/filegraph/apis/docconvert-api/revisions/436255c85bd4?raw)
