pdf-mcp Documentation
Browse documentation
Markdown

Zapier integration

Call pdf-mcp from a Zap with Webhooks by Zapier

On this page

Call pdf-mcp from a Zapier Zap with Webhooks by Zapier. The same setup works for invoices, reports, certificates, and other HTML-based documents.

What Zapier does

Zapier connects more than 5,000 apps without code. A Zap can call pdf-mcp to:

  • Generate PDFs when form responses are submitted
  • Create invoices automatically from payment events
  • Produce reports when spreadsheet rows are added
  • Convert HTML templates to PDFs in any Zap

Before you start

  1. A Zapier account (Free or paid plan)
  2. A pdf-mcp account with an API key (Get your API key)
  3. Basic familiarity with Zapier Zaps

Quick setup

Step 1: Create a Zap

  1. Log into zapier.com and click Create Zap
  2. Set up your trigger (the event that starts the Zap)
  3. Add an action step and search for Webhooks by Zapier

Step 2: Configure the webhook action

  1. Select Webhooks by Zapier as your action app
  2. Choose POST as the action event
  3. Click Continue to configure the webhook

Step 3: Set up the request

Configure the webhook with these settings:

FieldValue
URLhttps://api.pdf-mcp.io/htmlToPdf
Payload Typejson
DataYour HTML content (see below)
HeadersAuthorization: Bearer YOUR_API_KEY
HeadersContent-Type: application/json

Replace YOUR_API_KEY with your actual API key from the dashboard.


Webhook settings

Basic settings

SettingValue
URLhttps://api.pdf-mcp.io/htmlToPdf
Payload Typejson

Headers

Add these headers to authenticate and specify content type:

HeaderValue
AuthorizationBearer YOUR_API_KEY
Content-Typeapplication/json

Data fields

Configure the JSON payload with these fields:

FieldValue
htmlYour HTML content or mapped field from trigger
filenamedocument.pdf or dynamic filename
cssOptional CSS styles

Configure the webhook

1. Add the webhook action

After your trigger, click the + button and search for “Webhooks by Zapier”:

  1. Select Webhooks by Zapier
  2. Choose POST as the event
  3. Click Continue

2. Configure the URL

Enter the pdf-mcp API endpoint:

Plain text
https://api.pdf-mcp.io/htmlToPdf

3. Set the payload type

Select json from the dropdown.

4. Add data fields

Add the required fields:

Field 1:

  • Key: html
  • Value: Your HTML content (can be static or dynamic from trigger)

Field 2 (optional):

  • Key: filename
  • Value: document.pdf (or use dynamic data)

Field 3 (optional):

  • Key: css
  • Value: @page { size: A4; margin: 2cm; }

5. Configure headers

Add two headers:

Header 1:

  • Key: Authorization
  • Value: Bearer YOUR_API_KEY

Header 2:

  • Key: Content-Type
  • Value: application/json

6. Test the webhook

Select Test step. A successful request returns the PDF data.


Dynamic HTML with Zapier fields

Use Zapier’s field mapping to create dynamic PDFs from your trigger data.

Form response example

If your trigger is a form submission (Google Forms, Typeform, etc.), map the fields:

Data field html:

HTML
<h1>Form Submission</h1>
<p><strong>Name:</strong> {{Name}}</p>
<p><strong>Email:</strong> {{Email}}</p>
<p><strong>Message:</strong> {{Message}}</p>
<p><em>Submitted on {{Date}}</em></p>

Replace {{Name}}, {{Email}}, etc. with the actual field mappings from your trigger by clicking in the value field and selecting from the dropdown.

Payment invoice example

If your trigger is Stripe or PayPal:

Data field html:

HTML
<!DOCTYPE html>
<html>
<head><title>Invoice</title></head>
<body>
  <h1>Invoice #{{Invoice Number}}</h1>
  <p>Customer: {{Customer Name}}</p>
  <p>Email: {{Customer Email}}</p>
  <table style="width:100%; border-collapse:collapse;">
    <tr style="background:#f0f0f0;">
      <th style="border:1px solid #ddd; padding:8px;">Description</th>
      <th style="border:1px solid #ddd; padding:8px;">Amount</th>
    </tr>
    <tr>
      <td style="border:1px solid #ddd; padding:8px;">{{Product Name}}</td>
      <td style="border:1px solid #ddd; padding:8px;">${{Amount}}</td>
    </tr>
  </table>
  <p><strong>Total: ${{Amount}}</strong></p>
</body>
</html>

Data field filename:

Plain text
invoice-{{Invoice Number}}.pdf

Zap examples

1. Google Form to PDF receipt

Plain text
[Google Forms: New Response] → [Webhooks: POST to pdf-mcp] → [Gmail: Send Email with Attachment]

Trigger: Google Forms - New Form Response Action 1: Webhooks by Zapier - POST with form data as HTML Action 2: Gmail - Send Email, attach the PDF from webhook response

2. Stripe payment to invoice PDF

Plain text
[Stripe: New Payment] → [Webhooks: POST to pdf-mcp] → [Dropbox: Upload File]

Trigger: Stripe - New Payment Action 1: Webhooks by Zapier - POST with invoice HTML Action 2: Dropbox - Upload File with PDF data

3. Google Sheets to certificate

Plain text
[Google Sheets: New Row] → [Webhooks: POST to pdf-mcp] → [Email: Send Certificate]

Trigger: Google Sheets - New Spreadsheet Row Action 1: Webhooks by Zapier - Generate certificate PDF Action 2: Send certificate via email

4. Airtable record to report

Plain text
[Airtable: New Record] → [Webhooks: POST to pdf-mcp] → [Google Drive: Upload File]

Trigger: Airtable - New Record Action 1: Webhooks by Zapier - Generate report PDF Action 2: Google Drive - Upload to specific folder


API endpoints

Configure your webhook with these endpoints:

EndpointMethodDescription
/htmlToPdfPOSTConvert HTML to PDF
/textToPdfPOSTConvert plain text to PDF
/imageToPdfPOSTConvert images to PDF
/pdfToImagePOSTConvert PDF pages to images
/extractTextPOSTExtract text from PDF
/extractPagesPOSTExtract specific pages
/mergePdfsPOSTCombine multiple PDFs
/pageCountPOSTGet PDF page count

See the API reference for request and response details.


cURL examples

Test the API directly before configuring Zapier:

Basic HTML to PDF request

Shell
curl -X POST https://api.pdf-mcp.io/htmlToPdf \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "html": "<h1>Hello, World!</h1><p>Generated from Zapier workflow.</p>"
  }' \
  --output document.pdf

Styled invoice

Shell
curl -X POST https://api.pdf-mcp.io/htmlToPdf \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "html": "<!DOCTYPE html><html><head><title>Invoice</title></head><body><h1>Invoice #12345</h1><table><tr><th>Item</th><th>Amount</th></tr><tr><td>Service Fee</td><td>$99.00</td></tr></table><p>Total: $99.00</p></body></html>",
    "css": "@page { size: A4; margin: 2cm; } body { font-family: Arial, sans-serif; } table { width: 100%; border-collapse: collapse; } th, td { border: 1px solid #ddd; padding: 8px; }",
    "filename": "invoice-12345.pdf"
  }' \
  --output invoice-12345.pdf

Text to PDF

Shell
curl -X POST https://api.pdf-mcp.io/textToPdf \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "text": "Meeting Notes\n\nDate: January 15, 2025\n\n1. Project status review\n2. Timeline discussion\n3. Next steps",
    "filename": "meeting-notes.pdf"
  }' \
  --output meeting-notes.pdf

MCP clients

For an MCP client, enter the hosted Streamable HTTP URL directly. There is no pdf-mcp package or local server to install. See the verified MCP client setup guide.


Handle the response

The Webhooks action returns the PDF as binary data. Map that output into the next action that needs the file.

Send by email

Use Gmail, Outlook, or SMTP actions to send the PDF as an attachment:

  1. Add an email action after the webhook
  2. In the attachment field, select the response body from the webhook step
  3. Set the attachment filename (e.g., document.pdf)

Upload to cloud storage

Use Google Drive, Dropbox, or OneDrive actions:

  1. Add a file upload action after the webhook
  2. Map the webhook response body to the file content
  3. Specify the destination folder and filename

Save to a CRM

Some CRMs (Salesforce, HubSpot) accept file attachments:

  1. Use the CRM’s “Add Attachment” or “Upload File” action
  2. Map the PDF data from the webhook response

Error handling

Zapier can notify you about failures or route them through a separate path.

Common status codes

CodeDescriptionSolution
200SuccessPDF generated successfully
401UnauthorizedCheck your API key in headers
402Payment RequiredAdd credits to the account
403ForbiddenVerify API key permissions
400Bad RequestCheck your request body format
500Server ErrorReview HTML syntax or contact support

Set up error notifications

  1. Go to your Zap settings
  2. Enable Error notifications
  3. Choose to be notified by email when the Zap fails

Use paths for errors

Add a Paths action after the webhook to handle success/failure differently:

Plain text
[Webhook] → [Paths]
              ├── Path A: Status = 200 → [Continue with PDF]
              └── Path B: Status != 200 → [Send Alert Email]

Troubleshooting

PDF is empty or not generated

  • Verify your API key is correct and has credits
  • Check that the html field contains valid HTML
  • Ensure headers are correctly formatted
  • Test with a simple HTML string first

Authentication errors (401/403)

  • Check the Authorization header format: Bearer YOUR_API_KEY
  • Ensure there’s a space between “Bearer” and your key
  • Verify your API key hasn’t been revoked

Insufficient credits (402)

  • Check your credit balance in the dashboard

Webhook timeout

  • Large or complex HTML may take longer to process
  • Simplify your HTML template
  • Use inline styles instead of external resources

Data mapping issues

  • Click into the field value to see available mappings
  • Use Zapier’s Formatter action to prepare data
  • Test each step individually before running the full Zap

Binary data not recognized

  • Some downstream actions may not accept binary data directly
  • Use a Code step to base64 encode if needed
  • Check the specific app’s documentation for file upload requirements

Implementation notes

Performance

  • Keep HTML simple for faster generation
  • Use inline CSS instead of external stylesheets
  • Avoid large images - use compressed versions

Reliability

  • Test your Zap thoroughly before turning it on
  • Use Zapier’s built-in error notifications
  • Monitor your API credit balance

Security

  • Never share your API key publicly
  • Use Zapier’s secure storage for sensitive data
  • Review your Zap’s data exposure

Credit usage

  • Batch similar operations when possible
  • Use filters to only generate PDFs when necessary
  • Monitor your credit usage in the dashboard


Credit usage

Zapier requests use the same credits as direct API requests:

  • HTML to PDF: 1 credit for the first page, plus 0.01 per additional page
  • Render template: 1 credit for the first page, plus 0.01 per additional page
  • PDF to image: 1 credit for the first page, plus 0.01 per additional page
  • AI template generation: 1 credit per successful message
  • Other PDF utilities, including form operations and file search: 0.01 credits per request
  • Direct file, template, asset, and theme management: free

The dashboard shows current usage.