Generate and Email PDF Invoices from Caspio Using PDF.co and Zapier

9 Minutes Read

This tutorial shows how to generate a PDF invoice whenever a new record is added to Caspio and send the finished document as a Gmail attachment.

Workflow

Caspio → PDF.co HTML to PDF Converter → Gmail

Step 1: Create the Caspio Trigger

Create a new Zap and select Caspio as the trigger app.

Choose New Record, then:

  1. Connect your Caspio account.
  2. Select the table containing the invoice data.
  3. Choose the appropriate event source.
  4. Test the trigger and select a sample invoice record.

The sample should include the fields required for the invoice, such as:

  • Invoice number and date
  • Customer name and address
  • Item description
  • Quantity and price
  • Total amount
  • Customer email address

Step 2: Add the PDF.co Action

Add an action and select PDF.co → HTML to PDF Converter.

Click Sign in when Zapier asks you to connect an account. Sign in to PDF.co in the authorization window and approve access.

Configure the action:

  • Input Type: Raw HTML
  • Page Orientation: Portrait
  • Page Size: Letter or A4
  • Custom Margins: 20px
  • Render Page Background: Yes
  • Media Type: Print
  • File Name: Map the invoice number, such as Invoice-12345.pdf

Step 3: Create the Invoice HTML

In the HTML field, add an invoice layout and insert the corresponding Caspio fields through Zapier’s data picker.

For example:

<!doctype html>
<html>
<head>
  <meta charset="utf-8">
  <style>
    body {
      font-family: Arial, sans-serif;
      color: #222;
      padding: 20px;
    }
    h1 {
      color: #2457a6;
      margin-bottom: 4px;
    }
    .details {
      margin: 24px 0;
    }
    table {
      width: 100%;
      border-collapse: collapse;
    }
    th, td {
      padding: 10px;
      border-bottom: 1px solid #ddd;
      text-align: left;
    }
    .amount {
      text-align: right;
    }
    .total {
      margin-top: 20px;
      text-align: right;
      font-size: 18px;
      font-weight: bold;
    }
  </style>
</head>
<body>
  <h1>Invoice</h1>
  <p>Invoice Number: CASPIO_INVOICE_NUMBER</p>
  <p>Invoice Date: CASPIO_INVOICE_DATE</p>

  <div class="details">
    <strong>Bill To:</strong><br>
    CASPIO_CUSTOMER_NAME<br>
    CASPIO_CUSTOMER_ADDRESS
  </div>

  <table>
    <thead>
      <tr>
        <th>Description</th>
        <th>Quantity</th>
        <th class="amount">Price</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td>CASPIO_ITEM_DESCRIPTION</td>
        <td>CASPIO_QUANTITY</td>
        <td class="amount">CASPIO_PRICE</td>
      </tr>
    </tbody>
  </table>

  <div class="total">
    Total: CASPIO_TOTAL
  </div>
</body>
</html>

Replace each CASPIO_... placeholder by inserting the matching field from the Caspio trigger.

For descriptions of the PDF.co settings, see the HTML to PDF Converter documentation.

Step 4: Test the PDF Generation

Test the PDF.co action.

Confirm that the result includes a temporary PDF URL. Open the URL and verify that:

  • The correct Caspio values appear.
  • Prices and totals are formatted properly.
  • The invoice fits the selected page size.
  • The filename includes the invoice number.

Step 5: Email the Invoice

Add Gmail as the final action and select Send Email.

Configure:

  • To: Map the customer email address from Caspio.
  • Subject: Map the invoice number into a subject such as Invoice 12345.
  • Body: Add a short message explaining that the invoice is attached.
  • Attachments: Map the PDF URL returned by PDF.co.

Example message:

Hello,

Please find your invoice attached. Contact us if you have any questions.

Thank you.

Test the action and confirm that Gmail sends the generated PDF as an attachment.

Step 6: Publish the Zap

Publish the Zap after all three steps pass their tests.

Whenever Caspio creates a new invoice record, Zapier will generate the PDF with PDF.co and send it to the customer through Gmail.

Conclusion

This workflow automatically turns Caspio invoice data into a formatted PDF and delivers it as an email attachment, reducing manual document preparation and helping ensure consistent invoice formatting.

Related Tutorials

See Related Tutorials