POST/v1/convert/html

Convert HTML to PDF

Send raw HTML content directly and get a base64-encoded PDF response. Best for server-rendered templates, email receipts, and generated markup where you want full control over the rendered payload.

data_object

Parameters

html
stringbodyrequired

Complete HTML document (recommended) or HTML fragment. Use inline CSS or embedded <style> tags for deterministic rendering.

config
objectbody

Optional render configuration. Include page dimensions, margins, timing controls, and output metadata.

css
stringbody

Optional stylesheet content uploaded alongside the HTML payload. Use this when you want to keep styles separate from the markup instead of embedding <style> tags.

header
stringbody

Optional complete HTML document rendered in the top margin area of each page. Use inline styles because it renders separately from the main document.

footer
stringbody

Optional complete HTML document rendered in the bottom margin area of each page. Same isolation rules as header apply.

bolt

Common HTML flow

  1. 1Generate HTML using your backend template engine.
  2. 2Pass styles either inline, inside <style>, or through the optional css field.
  3. 3Add header and footer HTML when you need repeated page chrome.
  4. 4Pass print_background for full visual parity with web output.
  5. 5Decode and persist the PDF bytes where needed.

HTML endpoint examples

POST/v1/convert/html
curl -X POST https://api.fastpdf.dev/v1/convert/html \ -H "X-API-Key: YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "html": "<h1>Hello, World!</h1>", "config": { "paper": { "width": "8.5in", "height": "11in" }, "margin": { "top": "1in", "bottom": "1in" }, "print_background": true }}' \ --output document.pdf
{ "content": "JVBERi0xLjQKJeLjz9MKMyAwIG9iago..."}