# HTML to PDF in Zapier

Convert HTML or URLs to PDF in Zapier with Webhooks by Zapier and the html-pdf.com API, then attach the PDF in Gmail, Drive or Slack.

**Quick answer.** Add a **Webhooks by Zapier → Custom Request** step with these settings. You get back a PDF link you can map into the next step.

- **Method:** `POST`
- **URL:** `https://html-pdf.com/v1/pdf`
- **Headers:** `Authorization` = `Bearer hp_live_...` and `Content-Type` = `application/json`
- **Data:** `{"html": "<h1>Hello</h1>", "response": "url"}`

## Get an API key

This step gives you a key. Get one by email at https://html-pdf.com/login, or with one call:

```bash
curl -X POST https://html-pdf.com/v1/signup \
  -H "Content-Type: application/json" \
  -d '{"email": "you@example.com"}'
```

Then open the link we email you to confirm your address, which adds the 100 free credits. 1 credit = 1 PDF page, and no card is needed. Webhooks by Zapier is a built-in app, but your Zapier plan must include it.

## Connect

Here is the full step setup. Add an action step, **Webhooks by Zapier → Custom Request**.

- **Method:** `POST`
- **URL:** `https://html-pdf.com/v1/pdf`
- **Data:** the raw JSON body. Asking for a link is easiest in Zapier.

```json
{
  "html": "<h1>Receipt for {{name}}</h1><p>Amount: {{amount}}</p>",
  "format": "A4",
  "margin": "15mm",
  "filename": "receipt.pdf",
  "response": "url"
}
```

- **Headers:**
  - `Authorization`: `Bearer hp_live_...`
  - `Content-Type`: `application/json`

Insert your trigger's fields where the `{{...}}` placeholders are. Test the step. The response contains `url`, `pages`, `credits_remaining` and `expires_at`.

**Use the PDF:** in the next step (Gmail "Send Email" attachments, Google Drive "Upload File", Slack "Upload File"), map the `url` field into the **File** field. Zapier downloads the file from the link. The link is valid for 24 hours.

For a web page, send `{"url": "https://example.com", "response": "url"}`.

If you leave out `"response": "url"`, the API returns the binary PDF. Zapier handles binary responses as an internal file reference, which is harder to map. That's why the link is the recommended setup.

## Try it

These two Zaps show common ways to use the step.

- New Stripe payment → Custom Request (receipt PDF) → Gmail with the PDF attached.
- New Typeform entry → Formatter (build HTML) → Custom Request → Google Drive.

## Tips

These settings help with layout and cost.

- **Escape quotes:** if a mapped field can contain `"`, clean it with a Formatter step first, or the JSON breaks.
- **Page breaks:** `<div style="break-before: page"></div>` between sections.
- **Page numbers:** `"footer_html": "<div style='font-size:9px;width:100%;text-align:center'><span class='pageNumber'></span> / <span class='totalPages'></span></div>"` with a margin.
- **Set `max_pages`.** Renders over the limit fail and cost nothing.

## Troubleshooting

Most problems come from broken JSON or the auth header.

- **400 `invalid_json`:** a mapped field broke the body. Check quotes and line breaks.
- **401:** the header must be exactly `Bearer ` followed by your key. You can also send it as an `X-API-Key` header.
- **403 `email_not_confirmed`:** the email behind the key isn't confirmed yet. Click the link we emailed you (it adds the 100 free credits), then test the Zap again.
- **402 `insufficient_credits`:** top up at https://html-pdf.com/login. Credits never expire and there is no subscription.

## FAQ

### How do I create a PDF in Zapier?

Add a Webhooks by Zapier **Custom Request** step that posts your HTML to `https://html-pdf.com/v1/pdf` with `"response": "url"`. Then map the returned `url` into the File field of the next step.

### How do I attach the PDF to a Gmail email in Zapier?

Map the `url` field from the Custom Request step into the Gmail "Send Email" attachments field. Zapier downloads the file from the link, which stays valid for 24 hours.

### Is there a free HTML to PDF option for Zapier?

Yes. New html-pdf.com accounts get 100 free credits once, with no card. Your Zapier plan does need to include Webhooks by Zapier.

### Do credits expire?

No. Purchased credits never expire and there is no subscription. Packs start at $10 for 1,000 credits, and failed renders cost nothing.

Full reference: [API docs](https://html-pdf.com/docs) · [MCP server](https://html-pdf.com/mcp)
