Call pdf-mcp from an n8n workflow with an HTTP Request node. The same setup works for invoices, reports, certificates, and other HTML-based documents.
What n8n does
n8n connects apps and services in automated workflows. A workflow can call pdf-mcp to:
- Generate PDFs from form submissions or webhooks
- Create invoices automatically when orders are placed
- Produce reports on a schedule
- Convert HTML templates to PDFs in any workflow
Before you start
- An n8n instance (cloud or self-hosted)
- A pdf-mcp account with an API key (Get your API key)
- Basic familiarity with n8n workflows
Quick setup
Step 1: Add credentials
- In n8n, go to Credentials in the left sidebar
- Click Add Credential
- Search for and select Header Auth
- Configure the credential:
- Name:
pdf-mcp API - Name:
Authorization - Value:
Bearer YOUR_API_KEY
- Name:
- Click Save
Replace YOUR_API_KEY with your actual API key from the dashboard.
Step 2: Add the request node
- Add an HTTP Request node to your workflow
- Configure it using the settings below or import the ready-to-use JSON
HTTP Request node settings
Basic settings
| Setting | Value |
|---|---|
| Method | POST |
| URL | https://api.pdf-mcp.io/htmlToPdf |
| Authentication | Header Auth |
| Credential | pdf-mcp API (created above) |
Headers
| Header | Value |
|---|---|
| Content-Type | application/json |
JSON body
{
"html": "<h1>Hello from n8n!</h1><p>This PDF was generated automatically.</p>",
"filename": "document.pdf"
}Node JSON to import
Paste this JSON into n8n to create a configured HTTP Request node:
HTML to PDF node
{
"parameters": {
"method": "POST",
"url": "https://api.pdf-mcp.io/htmlToPdf",
"authentication": "genericCredentialType",
"genericAuthType": "httpHeaderAuth",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "Content-Type",
"value": "application/json"
}
]
},
"sendBody": true,
"bodyParameters": {
"parameters": [
{
"name": "html",
"value": "={{ $json.html }}"
},
{
"name": "filename",
"value": "={{ $json.filename || 'document.pdf' }}"
}
]
},
"options": {
"response": {
"response": {
"responseFormat": "file"
}
}
}
},
"name": "Generate PDF",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2
}To import it:
- Copy the JSON above
- In your n8n workflow, press
Ctrl+V(orCmd+Von Mac) - The node will be added to your canvas
- Connect your Header Auth credential
Dynamic HTML with expressions
Use n8n expressions to generate dynamic content from previous nodes:
Invoice example
{
"parameters": {
"method": "POST",
"url": "https://api.pdf-mcp.io/htmlToPdf",
"authentication": "genericCredentialType",
"genericAuthType": "httpHeaderAuth",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "Content-Type",
"value": "application/json"
}
]
},
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={{ JSON.stringify({ html: `<!DOCTYPE html><html><head><title>Invoice</title></head><body><h1>Invoice #${$json.invoice_number}</h1><p>Customer: ${$json.customer_name}</p><table style=\"width:100%; border-collapse:collapse;\"><tr style=\"background:#f0f0f0;\"><th style=\"border:1px solid #ddd; padding:8px;\">Item</th><th style=\"border:1px solid #ddd; padding:8px;\">Amount</th></tr><tr><td style=\"border:1px solid #ddd; padding:8px;\">${$json.item_description}</td><td style=\"border:1px solid #ddd; padding:8px;\">$${$json.amount}</td></tr></table><p><strong>Total: $${$json.amount}</strong></p></body></html>`, css: '@page { size: A4; margin: 2cm; }', filename: `invoice-${$json.invoice_number}.pdf` }) }}",
"options": {
"response": {
"response": {
"responseFormat": "file"
}
}
}
},
"name": "Generate Invoice PDF",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2
}The expression reads invoice_number, customer_name, item_description, and amount from the input data.
Workflow examples
1. Form submission to PDF
Trigger: Webhook or Form node receiving submissions
[Webhook] → [Generate PDF] → [Send Email with Attachment]2. Scheduled report
[Schedule Trigger] → [Database Query] → [Generate PDF Report] → [Upload to S3/Google Drive]3. Order confirmation invoice
[Stripe Webhook] → [Format Invoice Data] → [Generate Invoice PDF] → [Email to Customer]4. Certificate
[Google Sheets Trigger] → [Generate Certificate PDF] → [Send via Email]API endpoints
Configure your HTTP Request node with these endpoints:
| Endpoint | Method | Description |
|---|---|---|
/htmlToPdf | POST | Convert HTML to PDF |
/textToPdf | POST | Convert plain text to PDF |
/imageToPdf | POST | Convert images to PDF |
/pdfToImage | POST | Convert PDF pages to images |
/extractText | POST | Extract text from PDF |
/extractPages | POST | Extract specific pages |
/mergePdfs | POST | Combine multiple PDFs |
/pageCount | POST | Get PDF page count |
See the API reference for request and response details.
cURL examples
Test the API directly before configuring n8n:
Basic HTML to PDF request
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 n8n workflow.</p>"
}' \
--output document.pdfStyled invoice
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.pdfText to PDF
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.pdfMCP 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 HTTP Request node returns the PDF as binary data. Pass that output to the next node that needs the file.
Save to a file
Use a Write Binary File node after the HTTP Request to save locally.
Send by email
Connect to an Email Send node (Gmail, SMTP, etc.) and attach the binary data.
Upload to cloud storage
Use nodes like AWS S3, Google Drive, or Dropbox to store generated PDFs.
Return it from a webhook
If your workflow was triggered by a webhook, use Respond to Webhook to return the PDF.
Error handling
Add an Error Trigger node to route failed requests.
Common status codes
| Code | Description | Solution |
|---|---|---|
| 200 | Success | PDF generated successfully |
| 401 | Unauthorized | Check your API key in credentials |
| 402 | Payment Required | Add credits to the account |
| 403 | Forbidden | Verify API key permissions |
| 400 | Bad Request | Check your request body format |
| 500 | Server Error | Review HTML syntax or contact support |
Error-handling workflow
[HTTP Request] → [IF Node (check status)] → [Success: Continue] or [Error: Send Alert]Troubleshooting
PDF is empty or not generated
- Verify your API key is correct and has credits
- Check that the
htmlfield contains valid HTML - Test with a simple HTML string first
Authentication errors
- Ensure the Header Auth credential has
Authorizationas the name - The value must be
Bearer YOUR_API_KEY(with a space after Bearer) - API key should not include quotes
Binary data issues
- Set
Response FormattoFilein node options - Make sure downstream nodes expect binary data
n8n expression errors
- Use the expression editor to validate expressions
- Escape special characters in template literals
- Test with hardcoded values first
Implementation notes
Performance
- Keep HTML simple for faster generation
- Use inline CSS instead of external stylesheets
- Batch operations when generating multiple PDFs
Reliability
- Add retry logic for transient failures
- Store generated PDFs in cloud storage for durability
- Log workflow executions for debugging
Security
- Never expose your API key in shared workflows
- Use n8n credentials system for secure storage
- Sanitize user input in HTML templates
Related documentation
- Quick start: get an API key
- HTML to PDF: endpoint details
- API reference: all available endpoints
- MCP server: AI agent integration
- Zapier integration: Zapier setup
- Make integration: Integromat/Make setup
Credit usage
n8n 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.