Skip to content

PDF Task

Overview

The PDF Task generates PDF documents from templates with dynamic data. Use it to create invoices, reports, certificates, contracts, proposals, receipts, or any professional document that needs to be generated programmatically.

When to use this task:

  • Generate invoices for orders
  • Create custom reports
  • Issue certificates or credentials
  • Generate contracts with client data
  • Produce proposals and quotes
  • Create receipts and statements
  • Build event tickets
  • Generate branded documents

Key Features:

  • HTML/CSS templates
  • Dynamic data injection
  • Professional styling
  • Page layout control (A4, Letter, etc.)
  • Headers and footers
  • Page numbering
  • Images and logos
  • Tables and lists
  • Multiple pages
  • PDF attachments in emails

Quick Start

Builder fields

The Field column is the label as it appears in the task builder; Key is the name the value is stored under and referenced by.

Field Key Type Default Notes
Action action select create_pdf Options: Create PDF · Add Password to PDF
Document Name Document Name textarea – Only shown when action is create_pdf
Password Password textarea – Only shown when action is create_pdf
Document Body Body richtext – Only shown when action is create_pdf
Document URL Document URL textarea – Only shown when action is add_password
Password Password textarea – Only shown when action is add_password
  1. Add PDF task
  2. Select or create template
  3. Insert dynamic data fields
  4. Configure page settings
  5. Test with sample data
  6. Use PDF in Email or store

Simple Example:

Template: Invoice
Data:
  Customer: {{task_47001_full_name}}
  Amount: {{task_43001_total}}
  Date: {{task_48001_current_date}}

Output: {{task_36001_pdf_url}}

Template Structure

Basic HTML Template

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <style>
      body {
        font-family: Arial, sans-serif;
        margin: 40px;
      }
      .header {
        text-align: center;
        margin-bottom: 30px;
      }
      .content {
        margin: 20px 0;
      }
    </style>
  </head>
  <body>
    <div class="header">
      <h1>Invoice</h1>
    </div>
    <div class="content">
      <p>Customer: {{customer_name}}</p>
      <p>Amount: {{total_amount}}</p>
    </div>
  </body>
</html>

Dynamic Data Injection

Use {{variable}} syntax to insert data:

<p>Dear {{task_47001_first_name}},</p>
<p>Your order {{task_46001_order_id}} has been confirmed.</p>
<p>Total: ${{task_43001_total}}</p>

CSS Styling

Professional invoice style:

body {
  font-family: 'Helvetica', Arial, sans-serif;
  color: #333;
  line-height: 1.6;
  margin: 0;
  padding: 40px;
}

.invoice-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 40px;
  padding-bottom: 20px;
  border-bottom: 2px solid #0066cc;
}

.company-info {
  font-size: 14px;
}

.invoice-meta {
  text-align: right;
  font-size: 12px;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0;
}

th {
  background: #0066cc;
  color: white;
  padding: 12px;
  text-align: left;
}

td {
  padding: 10px 12px;
  border-bottom: 1px solid #ddd;
}

.total-row {
  background: #f5f5f5;
  font-weight: bold;
  font-size: 16px;
}

Page Layout

Page settings:

<style>
  @page {
    size: A4; /* or Letter, Legal */
    margin: 20mm;
  }

  /* Page break control */
  .no-break {
    page-break-inside: avoid;
  }

  .page-break {
    page-break-after: always;
  }
</style>

Headers and Footers

<style>
  .header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 50px;
    background: #f8f8f8;
    text-align: center;
    padding: 15px;
  }

  .footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 40px;
    text-align: center;
    font-size: 10px;
    color: #666;
  }

  /* Content positioning */
  .content {
    margin-top: 80px;
    margin-bottom: 60px;
  }
</style>

<div class="header">Company Name | Invoice</div>

<div class="footer">Page <span class="pageNumber"></span> of <span class="totalPages"></span></div>

Page Configuration

Page Size

Page Size: A4 (default)

Options:

  • A4 (210mm × 297mm) - International standard
  • Letter (8.5" × 11") - US standard
  • Legal (8.5" × 14") - US legal
  • A3 (297mm × 420mm) - Large format

Orientation

Orientation: Portrait (default)

Options:

  • Portrait (vertical)
  • Landscape (horizontal)

Margins

Top: 20mm
Bottom: 20mm
Left: 15mm
Right: 15mm

Outputs

Field Type Example Notes
document_name string Invoice-1042.pdf The generated file's name.
document_url string https://…/Invoice-1042.pdf Link to the PDF. Pass this to an Email attachment or a Files task.
document_size_bytes number 18422 File size in bytes.
run boolean true
run_text string PDF created successfully.

Real-World Examples

Send a quote as a PDF

Form Submission
  └─ Match to Client   look the client up
      └─ PDF           generate the quote
          └─ Email     attach {{task_36001_document_url}}

Produce a certificate on completion

CRM Trigger  (status changed to "Complete")
  └─ PDF        generate the certificate
      └─ Email  send it to the client

Keep a copy on the client record

Webhook In
  └─ PDF        generate the document
      └─ Files  save it into the client's folder

Best Practices

Template Design

  1. Use standard fonts - Arial, Helvetica, Times for compatibility
  2. Test on different sizes - A4 vs Letter
  3. Consider printing - Use print-safe colors
  4. Responsive tables - Tables adapt to content
  5. Page breaks - Control where pages break

Data Management

  1. Validate before PDF - Check all required fields exist
  2. Format data first - Use Formatter tasks for dates/currency
  3. Provide defaults - Handle missing data gracefully
  4. Escape HTML - Prevent injection in dynamic content
  5. Test with real data - Use actual production examples

Performance

  1. Optimize images - Compress logos and graphics
  2. Simple CSS - Avoid complex layouts
  3. Limit page count - Split large documents
  4. Cache templates - Reuse common templates
  5. Async generation - Don't block workflow

Quality

  1. Professional styling - Match brand guidelines
  2. Consistent formatting - Same fonts/colors throughout
  3. Proper alignment - Tables and text aligned
  4. White space - Don't cram content
  5. Proofread - Check spelling and grammar

Troubleshooting

PDF Not Generating

Check:

  1. Template HTML valid?
  2. All variables have data?
  3. CSS syntax correct?
  4. Page size configured?

Debug: Test template with static data first

Content Cut Off

Issue: Text or tables cut off at edges

Solutions:

  • Increase page margins
  • Reduce content font size
  • Use page-break-inside: avoid for tables
  • Split across multiple pages

Images Not Showing

Issue: Logo or images missing

Causes:

  • Invalid image URL
  • Image not publicly accessible
  • Wrong image format

Solutions:

  • Use full HTTPS URLs
  • Host images on CDN
  • Use base64 encoded images
  • Test image URL in browser

Styling Not Applied

Issue: CSS not rendering

Check:

  • CSS in <style> tag in <head>?
  • Valid CSS syntax?
  • Specificity correct?
  • PDF engine limitations?

Note: Some advanced CSS may not be supported. Test thoroughly.

Variables Empty

Issue: {{variable}} shows as empty

Check:

  • Variable name correct?
  • Previous task executed successfully?
  • Data exists in source task?

Debug: View execution history of previous tasks

Frequently Asked Questions

What HTML/CSS is supported?

Most standard HTML4/CSS2. Limited CSS3 support. Test complex layouts thoroughly.

Can I use external CSS files?

No, CSS must be inline in <style> tags.

Can I use JavaScript?

No, PDFs are static. All logic must be in workflow.

What's maximum PDF size?

Recommended under 10MB. Large PDFs may timeout.

Can I add digital signatures?

Not natively. Use third-party signing service after generation.

Can I password protect PDFs?

Check BaseCloud documentation for password protection options.

How to add barcodes?

Generate barcode image URL (with Code task), then include as <img> in template.

Can I merge multiple PDFs?

Not directly. Generate separate PDFs or include all content in one template.


  • Formatter - Format dates/currency for PDF
  • Code Task - Generate dynamic content/QR codes
  • Email Task - Send PDF as attachment
  • Loop Task - Generate multiple PDFs