Skip to main content

Budibase

Prerequisites

  • A PolyDoc account and API key - sign up for free, no credit card required. The free plan includes 150 PDF conversions per month.
  • A Budibase account - sign up for free, no credit card required.

Use Case 1: Generate PDFs from App Data

Let users generate an invoice PDF from a Budibase invoice row and its related line items via a custom REST API connection.
Button click → REST query (PolyDoc API) → Download PDF

Add a REST API data source

Use invoices (one row per invoice) and invoice_items (line rows linked by invoice_number). Examples below - two tabs in Sheets; two tables or linked records elsewhere.

invoice_numberinvoice_dateinvoice_due_dateinvoice_subtotalinvoice_tax_rateinvoice_tax_amountinvoice_totalcustomer_namecustomer_emailcustomer_streetcustomer_citycustomer_country
INV-2026-0012026-01-152026-02-1412000.11201320John Doejohn.doe@example.com456 Customer AvenueBeautiful CityUK
invoice_numberquantitynamedescriptionpriceoriginal_price
INV-2026-0011Web Design ServicesCustom website design and development for company homepage800
INV-2026-0011Logo DesignProfessional logo design with 3 revision rounds300
INV-2026-0011SEO OptimizationSearch engine optimization for 10 target keywords100150

In Budibase, open Data tables from the workspace sidebar and create two tables that match the columns above - invoices for the header fields and invoice_items linked back to invoices via an invoice_number relationship. Seed one sample invoice row with three line items so you have data to render when you test in Step 4.

Then open Settings (gear icon) → ConnectionsAPIs Create custom and configure a workspace-level REST connection that Step 2 reads from:

  • Display name: PolyDoc
  • Base URL: https://api.polydoc.tech
  • Authentication → Add authentication → Bearer Token. Name: PolyDoc Bearer. Token: your PolyDoc API key (get one from the Dashboard). Budibase auto-builds the Authorization: Bearer … header at request time - don't add it manually.

Click Save, then Open in API Editor to land in Step 2.

budibase.app

Configure the PolyDoc endpoint

In the API Editor (opened from Step 1), configure a new query:

  • Name: Convert Invoice to PDF
  • Connection: PolyDoc - PolyDoc Bearer (the connection from Step 1)
  • Method: POST
  • URL: https://api.polydoc.tech/pdf/convert
  • Headers tab → Add header: X-Sandbox = true
  • Body tab → select raw (JSON) and paste the template below.

Replace YOUR_TEMPLATE_ID with your own template's short ID - find it in the Dashboard under Templates (e.g. a1b-c2d). The bindings use Budibase's Handlebars syntax - when the query runs from a screen (Step 3) or an automation (Use Case 2), each {{ invoiceRow.field }} reads from the row passed in as a binding. See Templates for how the invoice template consumes the templateData fields.

{
"source": "[template:YOUR_TEMPLATE_ID]",
"templateData": {
"invoice_number": "{{ invoiceRow.invoice_number }}",
"invoice_date": "{{ invoiceRow.invoice_date }}",
"invoice_due_date": "{{ invoiceRow.invoice_due_date }}",
"invoice_subtotal": {{ invoiceRow.invoice_subtotal }},
"invoice_tax_rate": {{ invoiceRow.invoice_tax_rate }},
"invoice_tax_amount": {{ invoiceRow.invoice_tax_amount }},
"invoice_total": {{ invoiceRow.invoice_total }},
"customer_name": "{{ invoiceRow.customer_name }}",
"customer_email": "{{ invoiceRow.customer_email }}",
"customer_street": "{{ invoiceRow.customer_street }}",
"customer_city": "{{ invoiceRow.customer_city }}",
"customer_country": "{{ invoiceRow.customer_country }}",
"items": {{ lineItemsQuery.data }}
}
}
budibase.app

Create a screen with a generate button

Back in your app's Design view, open the home screen and add a Table component bound to the invoices data table you created in Step 1. With the table selected, drop a Button component into the row template and set its text to Generate PDF.

Open the button's right-panel On click setting and chain two actions in order:

  • Execute Query → Datasource = PolyDoc, Query = Convert Invoice to PDF (the one from Step 2). Bind its invoiceRow input to Current row (the row the button was rendered in) and its lineItemsQuery input to a sibling Execute Query against invoice_items filtered by invoice_number = Current row's invoice_number.
  • Navigate To → URL = {{ Execute Query – Convert Invoice to PDF.data }} (the base64 data:application/pdf;base64,… URI that Step 4's Transformer produces). Tick Open in new tab - the browser opens the data URI as a PDF preview where the user can save it.

Click Preview in the top bar, navigate to the invoice list, and click Generate PDF on a row.

budibase.app

Handle the PDF response

The PolyDoc endpoint returns a binary PDF, but the Navigate To action from Step 3 expects a string URL and the browser only opens PDFs from http(s):// or data: URIs. Bridge the two with the query's Transformer tab:

// Return the binary PDF as a base64 data URI so
// Step 3's Navigate To action can open it in a new tab.
return "data:application/pdf;base64," + data;

Re-test the button from Step 3 - the PDF should now download with every field populated: customer address, both dates, subtotal/tax/total all rendered as numbers, and every line item visible (including the strikethrough original_price on items that have one).

budibase.app

Use Case 2: Automated PDF on Row Creation

Automatically generate and email a PDF whenever a new row is added to the invoices table, using a workspace Automation.
Row created → Execute query (PolyDoc) → Send Email

Create an automation with a Row Created trigger

From the workspace Home, click + Create → Automation. Give it a name (e.g. Email PDF on new invoice) and pick the Row created trigger card, then Save.

Budibase opens the automation editor with a single Row created node on the canvas. Click the node and, in the right-side panel, set Table to the invoices table from Use Case 1 Step 1. The trigger automatically exposes a steps.trigger.row object that Step 2 reads from.

budibase.app

Add an External REST API action

Click + after the trigger node and add an Execute query step. Pick the Convert Invoice to PDF query from Use Case 1 Step 2 - both use cases share that single query definition; no re-configuration needed.

Bind the query's inputs to the trigger payload:

  • invoiceRow = {{ steps.trigger.row }} - the row that just fired the trigger.
  • lineItemsQuery = the result of a sibling Execute query step against your invoice_items table that filters by invoice_number = {{ steps.trigger.row.invoice_number }}. Add the line-items query as the first step after the trigger so its result is available when the convert step runs.
budibase.app

Add a Send Email action

Click + after the Execute query step and pick Send Email (SMTP) from the Email category of the step picker. Configure:

  • To: {{ steps.trigger.row.customer_email }}
  • Subject: Your invoice {{ steps.trigger.row.invoice_number }}
  • Attachments: Add attachment → URL = {{ steps[<convert-query-step-id>].response }} - the binary PDF returned from Step 2's Execute query. Set the filename to invoice-{{ steps.trigger.row.invoice_number }}.pdf.
budibase.app

Test the automation

Click Run test in the top bar and supply a sample row that mirrors your seeded invoice. Confirm the email arrives with the PDF attached and every field populated. When it looks right, click Set live to activate the automation - from then on, every new row inserted into the invoices table fires the whole pipeline.