For developers

HTML to PDF API

Send HTML, a public URL or an .html file in one POST request and get a PDF back. Authenticate with an API key, set the page size in pixels, and handle a small, predictable JSON response.

Free plan: 10 conversions per day, no credit card.

curl -X POST https://www.cheap-pdf.com/generate-pdf-public \
  -F "apikey=YOUR_API_KEY" \
  -F "filename=hello.pdf" \
  -F "width=800" \
  -F "height=1000" \
  --form-string "fileorhtmlorurl=<h1>Hello from CheapPDF</h1>" \
  -o response.json

# The PDF is returned base64-encoded inside the JSON:
jq -r '.data.base64_pdf' response.json | base64 --decode > hello.pdf

Request and response

Send a POST to https://www.cheap-pdf.com/generate-pdf-public. Both multipart/form-data and URL-encoded bodies are accepted.

Request fields
FieldRequiredDescription
apikeyYesYour API key. Keep it on the server.
fileorhtmlorurlYesRaw HTML, a public URL, or an uploaded .html file (up to 5 MB).
filenameYesName for the PDF, for example invoice-1042.pdf.
width, heightNoPage size in pixels.
landscape, printBackgroundNoOrientation and background printing.

Success response (HTTP 200)

response.json
{
  "success": true,
  "data": {
    "status": "success",
    "code": 200,
    "message": "PDF generated successfully",
    "base64_pdf": "JVBERi0xLjQK...",
    "filename": "hello.pdf"
  }
}

The PDF is delivered base64-encoded in data.base64_pdf. Decode it and write the bytes to a file, as in the examples above.

Error response

error.json
{
  "success": false,
  "message": "Invalid API key, please get a new API key from the dashboard",
  "error": "invalid_api_key"
}

Supported input types

Raw HTML

Pass a complete HTML document (or fragment) as the fileorhtmlorurl field. Ideal for server-rendered invoices and reports.

Public URL

Pass an http(s) address. Pages must be publicly reachable; localhost, private networks and non-standard ports are rejected.

Uploaded .html file

Upload a single self-contained file as fileorhtmlorurl in a multipart request. Maximum 5 MB.

Authentication and integration workflow

  1. Create an API key

    Sign up on the Get Started page. You can start on the free plan without a credit card.

  2. Call from your server

    Store the key in an environment variable and send it in the apikey field. Never put it in browser-side code.

  3. Decode and store the PDF

    Read data.base64_pdf, decode it, and save or stream the bytes. Check success first.

Error handling, timeouts and retries

API error responses
HTTP statuserror valueMeaning and what to do
400api_key_requiredThe apikey field is missing. Add it.
400invalid_api_keyThe key is not recognised. Copy it again from your dashboard.
400free_plan_limit_reachedThe daily free allowance is used up. Upgrade, or try again tomorrow.
400subscription_inactiveThe subscription is not active. Renew it to continue.
400unsafe_urlThe URL targets a private or unsupported address. Use a public http(s) URL.
400No error codeThe input was empty, not valid HTML or URL, or an uploaded file was not .html or was over 5 MB.
405—The request was not a POST.
5xx / upstream—Rendering failed upstream. The response includes the upstream message when available.

Retry guidance. Do not retry 400 responses, because the same request will fail again. For 5xx responses or network timeouts, retry a small number of times with exponential backoff, and set a client timeout (the examples use 60 seconds). Per-plan timeouts and request rate limits are not published, so build your integration to tolerate slow responses.

Pricing and usage limits

Free

$0

  • 10 conversions per day
  • HTML file uploads up to 5 MB
  • No credit card required

Premium

$5 / month

  • Unlimited conversions, as described on our pricing page
  • API key access and priority support
  • Cancel any time

See the full pricing section for details.

HTML to PDF API FAQ

What is the API endpoint?

POST https://www.cheap-pdf.com/generate-pdf-public with the fields apikey, fileorhtmlorurl and filename, plus optional width and height in pixels.

What does the API return?

A JSON object. On success, data.base64_pdf contains the PDF encoded as base64 and data.filename holds the file name. On failure, success is false and message explains why.

How do I send HTML from cURL?

Use --form-string for the HTML field. With -F, curl treats a value that starts with < as a file path to read.

Is there an SDK?

No official SDK is published. The API is a single HTTP request, so any HTTP client works, and the language guides show complete examples.

Does the API support webhooks?

No webhook feature is currently documented. Conversions are synchronous: the PDF comes back in the response.

Can I convert pages behind a login?

Authenticated pages are not supported. Render the page to HTML on your server and send the HTML instead.

Start generating PDFs with the API

Create a free API key and make your first conversion in a few minutes.

Subscribe to Our Newsletter for Fast HTML to PDF Updates

Stay updated on new features for our fast, simple, and affordable HTML to PDF API.