---
title: Convert and Format raw HTML to PDF API
slug: pdf-from-html
url: https://apyhub.com/chisleroff/service/pdf-from-html
provider: Website Intelligence
categories: [Output Kit]
tags: [html, pdf, raw, format]
auth: api_key
version: 1.0.0
service_type: sync
endpoints: 1
atoms: 100
alias: chisleroff-convert-and-format-raw-html-to-pdf-api
---

# Convert and Format raw HTML to PDF API

Convert raw HTML into a PDF file with page size, margins, orientation, and background control. Built for invoices, reports, and exports.

## Endpoints

| Method | URL | Description | Atoms |
| --- | --- | --- | --- |
| POST | `https://api.eu.apyhub.com/chisleroff/pdf-from-html` | What it does Converts raw HTML into a PDF document. You send HTML plus optional page and margin set… | 100 |

## Endpoint reference

### PDF from HTML

`POST https://api.eu.apyhub.com/chisleroff/pdf-from-html` · 100 atoms · accepts `application/json` · returns `application/json`

| Parameter | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `html` | body | string | yes | Raw HTML content to convert to PDF (max 5,000,000 characters). |
| `landscape` | body | boolean | no | Page orientation: true for landscape, false for portrait. Default: `false`. |
| `page_size` | body | string | no | Page size: A4, Letter, Legal, A3, Tabloid. Default: `A4`. |
| `margin_top` | body | string | no | Top margin with CSS units. Default: `10mm`. |
| `margin_left` | body | string | no | Left margin with CSS units. Default: `10mm`. |
| `margin_right` | body | string | no | Right margin with CSS units. Default: `10mm`. |
| `margin_bottom` | body | string | no | Bottom margin with CSS units. Default: `10mm`. |
| `print_background` | body | boolean | no | Print background graphics. Default: `true`. |

#### Quickstart

Convert a small HTML snippet into a PDF file.

```bash
curl -X POST "https://api.eu.apyhub.com/chisleroff/pdf-from-html" \
  -H "apy-token: $APY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"html":"<html><body><h1>Hello, world!</h1></body></html>"}'
```

#### What you'll get back

Returns a binary file download containing the generated PDF.

## About

## What it does
HTML to PDF turns raw HTML into a PDF binary you can store, email, or attach to workflows. Send an HTML document in the required `body.html` field, and the response comes back as a PDF file.

Use the optional page settings to control how the document is rendered. You can switch between portrait and landscape with `landscape`, choose a paper format with `page_size` (`A4`, `Letter`, `Legal`, `A3`, or `Tabloid`), and tune the margins with `margin_top`, `margin_left`, `margin_right`, and `margin_bottom`. Set `print_background` when you need background colors and graphics preserved in the output.

This is a fit for invoice generation, report export, contract snapshots, and any workflow where HTML is already the source of truth. Build the page once in your app, send the rendered markup to HTML to PDF, and return a downloadable PDF without a manual print step.

Because the output is a binary PDF, it can slot directly into document pipelines, storage systems, or delivery jobs that expect a file rather than JSON.

## Usage

Base URL: `https://api.eu.apyhub.com` (default region — see
`GET https://apyhub.com/api/public/regions` for the rest).

Authenticate with an ApyHub API key in the `apy-token` header.
Full docs and a live playground: https://apyhub.com/chisleroff/service/pdf-from-html
