---
title: "Generate PDF from HTML Document"
method: POST
path: "/generate-pdf"
tags: ["pdf"]
---

# Generate PDF from HTML Document

`POST /generate-pdf`

## Request

- The document declares no server URL.
- Auth: none required

Allows you to pass a HTML document as a string into the endpoint and return a application/pdf document

## Headers

- `strip-anchor-tags` boolean
- `embed-remote-images` boolean
- `margin-top` integer
- `margin-bottom` integer
- `margin-left` integer
- `margin-right` integer
- `title` string, required
- `subject` string, required
- `print-background` boolean
- `emulate-media-type` string

## Request body `text/html`

- unknown

## Response `200`

Successfully returned a PDF

## Other responses

- `500`: Internal Server Error

## Changes

- **2026-07-13** `34b2e7b5feaf`: 1 info
  - added the new optional `header` request parameter `embed-remote-images`
- **2022-03-01** `06d2f85d75d3`: 1 warning
  - deleted the `header` request parameter `embed-remote-images`

[Operation history](https://skmtc.dev/ministryofjustice/apis/swagger-opg-pdf-generator/changes/generate-pdf/post.md)

---

[API](https://skmtc.dev/ministryofjustice/apis/swagger-opg-pdf-generator.md) - [All operations](https://skmtc.dev/ministryofjustice/apis/swagger-opg-pdf-generator/llms.txt) - [OpenAPI document](https://skmtc.dev/ministryofjustice/apis/swagger-opg-pdf-generator/revisions/34b2e7b5feaf?raw)
