PDFPipe

Guide

HTML to PDF in Zapier

Any Zap that produces structured data, a new payment, a submitted form, a closed deal, can also produce a PDF. This guide shows two ways to add PDF generation to a Zap: the no-code Webhooks by Zapier action and the scripted Code by Zapier action. Both call the same API endpoint and take under five minutes to wire up.

Overview

PDFPipe exposes a single JSON endpoint at POST https://api.pdfpipe.xyz/v1/pdf. You send HTML and options; you get back a PDF. Zapier has two built-in actions that can make outbound HTTP requests: Webhooks (point-and-click) and Code (JavaScript or Python). The most reliable and lowest-friction choice is Webhooks by Zapier with the POST method. Use Code by Zapier when you need to build the HTML dynamically from earlier step data before sending it.

Both approaches require a PDFPipe API key, which you can get from the pricing page. Store the key in Zapier's built-in secret storage (Storage by Zapier or a Zap input field) rather than pasting it directly into action fields.

Using Webhooks by Zapier

This is the recommended method for most Zaps. No code required.

  1. In your Zap editor, add a new action step and search for Webhooks by Zapier. Choose the POST event.
  2. Set URL to https://api.pdfpipe.xyz/v1/pdf.
  3. Set Payload Type to Json.
  4. Under Headers, add two entries:
    • Authorization: Bearer YOUR_API_KEY
    • Content-Type: application/json
  5. Under Data, add the JSON fields. You can inline static HTML or map a field from an earlier Zap step. A minimal example:
json
{
  "html": "<h1>Hello {{customer_name}}</h1><p>Your order #{{order_id}} is confirmed.</p>",
  "store": true,
  "options": {
    "format": "A4"
  }
}

Replace {{customer_name}} and {{order_id}} with Zapier field references from earlier steps. Setting "store": true tells the API to persist the PDF and return a URL rather than streaming raw bytes, which is what you want for Zap workflows.

After a successful test, the Webhooks step response will contain these fields you can use in later steps:

FieldTypeDescription
document_urlstringPublic HTTPS URL to the stored PDF file
document_idstringUnique identifier for the document, useful for auditing

Code by Zapier (JavaScript)

When you need to build the HTML body programmatically from multiple Zap fields, use the Code by Zapier action with the Run JavaScript event. The snippet below reads input fields you define in the Zapier editor, assembles an HTML document, calls the API, and returns the PDF URL as output.

In the Code step, define these Input Data fields and map them from earlier steps: apiKey, customerName, orderId, amount.

javascript
const { apiKey, customerName, orderId, amount } = inputData;

const html = `
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <style>
      body { font-family: sans-serif; padding: 48px; color: #1d1812; }
      h1 { font-size: 28px; margin-bottom: 8px; }
      .amount { font-size: 22px; font-weight: bold; color: #d23a1d; }
    </style>
  </head>
  <body>
    <h1>Order Confirmation</h1>
    <p>Hi ${customerName},</p>
    <p>Your order <strong>#${orderId}</strong> has been confirmed.</p>
    <p class="amount">Total: ${amount}</p>
  </body>
</html>
`;

const response = await fetch("https://api.pdfpipe.xyz/v1/pdf", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": `Bearer ${apiKey}`,
  },
  body: JSON.stringify({
    html,
    store: true,
    options: { format: "A4" },
  }),
});

if (!response.ok) {
  const detail = await response.text();
  throw new Error(`PDF render failed (${response.status}): ${detail}`);
}

const data = await response.json();

return {
  documentUrl: data.document_url,
  documentId: data.document_id,
};

The return object becomes the output of the Code step. Downstream Zap steps can reference documentUrl and documentId as field mappings.

Using the PDF URL downstream

Once you have the document_url from the Webhooks or Code step, you can pass it into any subsequent Zap action. A common pattern is to email the PDF link to a customer immediately after a payment or form submission.

  1. Add a Gmail or SendGrid action after the Webhooks step.
  2. In the Body field of the email, map the document_url output from the previous step. For example:
    Your invoice is ready: {Webhooks document_url}
  3. Test the step. The customer receives an email with a direct link to their PDF.

The stored PDF URL is stable and accessible without authentication, so you can also pass it to a Slack message, a HubSpot note, an Airtable field, or any other action that accepts a URL.

Common trigger patterns

PDF generation fits naturally after triggers that signal a completed transaction or data collection event. These are the most common starting points:

  • New Stripe payment: generate an invoice or receipt PDF and email it to the customer.
  • New Typeform response: render a summary or confirmation PDF from form field answers.
  • New HubSpot deal (stage change): produce a proposal or quote PDF when a deal reaches a target stage.
  • New Airtable record: turn a row of structured data into a formatted PDF report or certificate.
  • New Calendly booking: send a confirmation PDF with appointment details and next steps.
  • New WooCommerce order: generate a packing slip or order confirmation PDF.

In each case the pattern is the same: trigger fires, a Webhooks or Code step builds and sends the HTML, and the PDF URL flows into the next action.

Test your HTML in the live playground on the home page before wiring it into Zapier, then read the docs for all available options including margins, landscape orientation, and custom page sizes.

Get an API key →