HTML to PDF API

Convert HTML to PDF instantly

POST raw HTML, receive a PDF. Sync for pages under 200KB, async job queue for large documents up to 1MB. Powered by Chromium — full CSS and JavaScript support.

Quick start

Send raw HTML in the request body. The response is a binary PDF file ready to save or stream.

shell
curl -X POST "https://api.apibravo.com/htmltopdf/v1/render?format=A4&margin=10" \
  -H "Content-Type: text/html" \
  -H "X-RapidAPI-Key: YOUR_API_KEY" \
  -H "X-RapidAPI-Host: html-to-pdf37.p.rapidapi.com" \
  -d "<html><body><h1>Hello PDF</h1></body></html>" \
  --output output.pdf
javascript
const fs = require('fs');
const axios = require('axios');

const response = await axios.post(
  'https://api.apibravo.com/htmltopdf/v1/render?format=A4&margin=10',
  '<html><body><h1>Hello PDF</h1></body></html>',
  {
    headers: {
      'Content-Type': 'text/html',
      'X-RapidAPI-Key': 'YOUR_API_KEY',
      'X-RapidAPI-Host': 'html-to-pdf37.p.rapidapi.com'
    },
    responseType: 'arraybuffer'
  }
);
fs.writeFileSync('output.pdf', response.data);
python
import requests

response = requests.post(
    'https://api.apibravo.com/htmltopdf/v1/render?format=A4&margin=10',
    data='<html><body><h1>Hello PDF</h1></body></html>'.encode(),
    headers={
        'Content-Type': 'text/html',
        'X-RapidAPI-Key': 'YOUR_API_KEY',
        'X-RapidAPI-Host': 'html-to-pdf37.p.rapidapi.com'
    }
)
with open('output.pdf', 'wb') as f:
    f.write(response.content)
php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.apibravo.com/htmltopdf/v1/render?format=A4');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, '<html><body><h1>Hello PDF</h1></body></html>');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Content-Type: text/html',
    'X-RapidAPI-Key: YOUR_API_KEY',
    'X-RapidAPI-Host: html-to-pdf37.p.rapidapi.com'
]);
$pdf = curl_exec($ch);
curl_close($ch);
file_put_contents('output.pdf', $pdf);

Endpoints

Sync render

POST /v1/render All plans · 200KB max

Submit raw HTML and receive a PDF immediately. Best for documents under 200KB.

HeaderValue
Content-Typetext/html

Create async job

POST /v1/jobs Paid plans · 1MB max

Submit HTML up to 1MB. Returns a job ID to poll. Available on Pro, Ultra, and Mega plans.

json response
{ "job_id": "550e8400-e29b-41d4-a716-446655440000", "status": "pending" }

Get job status

GET /v1/jobs/:id Paid plans

Poll until status is completed or failed. The download_url is valid for 24 hours.

json response
{
  "job_id": "550e8400-e29b-41d4-a716-446655440000",
  "status": "completed",
  "download_url": "https://pub-xxx.r2.dev/pdfs/550e8400.pdf",
  "created_at": "2024-01-01T00:00:00Z"
}
StatusMeaning
pendingQueued, not yet started
processingCurrently rendering
completedPDF ready — download_url included
failedRender failed — error field included

Render options

Pass as query parameters. All optional.

ParamDefaultValuesDescription
formatA4A4, Letter, LegalPage format
orientationportraitportrait, landscapePage orientation
margin100 – 50Margin in mm, all sides
printBackgroundtruetrue, falsePrint background colors and images
waitFor00 – 5000Milliseconds to wait before rendering

Error codes

StatusMeaning
400Invalid params or empty body
401Missing or invalid API key
403Async jobs require a paid plan
413HTML exceeds size limit for this endpoint
429Rate limit exceeded for your plan
503Render queue full — retry shortly

Pricing

All plans on RapidAPI. Upgrade or downgrade any time. No contracts.

Basic
$0
per month
200 requests/mo
Hard limit, no overage
10 req/min
Sync only
Get started free
Ultra
$25
per month
15,000 requests/mo
$0.003 per extra
60 req/min
Async jobs
Subscribe
Mega
$60
per month
50,000 requests/mo
$0.001 per extra
500 req/min
Async jobs
Subscribe