Pay-per-use · No subscriptions

Generate Invoice PDFs via API in Seconds

Render pixel-perfect invoice PDFs from HTML templates. Pay per page.

HTML2DocHub is the fastest way to generate invoice PDFs programmatically. Pass your HTML invoice template with dynamic data, get back a signed URL to a PDF. Supports async generation with webhook callbacks for bulk invoice runs.

Why developers choose HTML2DocHub

Pass dynamic HTML invoice templates with any data
Supports custom fonts, logos, and styles
Async generation — webhook callback on completion
Bulk invoice generation via async queue
Signed download URLs with configurable expiry
Idempotency keys to prevent duplicate invoice generation
A4, Letter, and custom page formats
Pay per invoice rendered — no subscription overhead

Code Examples

Node.js – Generate Invoice PDFnode
const invoiceHtml = `<!DOCTYPE html>
<html>
<head>
  <style>
    body { font-family: Arial, sans-serif; padding: 40px; }
    .header { display: flex; justify-content: space-between; margin-bottom: 40px; }
    .logo { color: #6366f1; font-size: 24px; font-weight: bold; }
    table { width: 100%; border-collapse: collapse; }
    th { background: #f8fafc; padding: 10px; text-align: left; border-bottom: 2px solid #e2e8f0;...`;

const response = await fetch("https://api.html2dochub.com/v1/render", {
  method: "POST",
  headers: {
    "X-API-Key": "sk_live_YOUR_KEY",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    type: "pdf",
    html: invoiceHtml,
    options: {
      format: "A4",
      print_background: true,
      margin_top: "1.5cm",
      margin_bottom: "1.5cm",
    },
    tag: "invoice",  // tag for filtering in dashboard
  }),
});

const { download_url, final_cost } = await response.json();
// Send download_url to customer email
Python – Bulk Invoice Generation (async)python
import requests

INVOICE_TEMPLATE = open("invoice_template.html").read()

def generate_invoice(invoice_data: dict) -> str:
    """Render invoice PDF and return download URL."""
    html = INVOICE_TEMPLATE.format(**invoice_data)

    resp = requests.post(
        "https://api.html2dochub.com/v1/render",
        headers={"X-API-Key": "sk_live_YOUR_KEY"},
        json={
            "type": "pdf",
            "mode": "async",
            "html": html,
            "options": {"format": "A4"},
            "webhook_url": "https://yourapp.com/webhooks/invoice-ready",
            "idempotency_key": f"invoice-{invoice_data['invoice_id']}",
            "tag": "invoice",
        },
    )
    data = resp.json()
    return data["job_id"]  # Poll or wait for webhook

Simple, transparent pricing

Pay only for pages rendered. No subscriptions. No minimum monthly fee.

1 page PDF:~₹0.10
10 page PDF:~₹0.80
100 pages/day:~₹8/day
See full pricing details

Frequently Asked Questions

Can I use custom HTML templates for invoices?+
Yes. Pass any HTML with your CSS, fonts, and logos. Use template engines like Jinja2, Handlebars, or EJS to inject dynamic data before sending.
How do I handle bulk invoice generation?+
Use async mode with `mode: 'async'` and a `webhook_url`. Your server receives a callback when each invoice is ready.
How long are download URLs valid?+
Default expiry is 1 hour. You can request longer expiry via support. Files are stored in S3 for 30 days.
Can I prevent duplicate invoice rendering?+
Yes — use the `idempotency_key` field. If you submit the same key twice, the second call returns the original job's result.

Start rendering PDFs today

Free account. No credit card required. API ready in minutes.

Get your free API key