Guides / Generate PDFs in Bubble

No-code · Updated 2026-12-03

Generate PDFs in Bubble

This guide takes an Invoice thing in your Bubble database, with its line items, and turns it into a finished PDF with one workflow action. The PDF is laid out by a template, totals are calculated for you, and the file is saved back onto the invoice.

It uses Bubble's API Connector plugin. A native DevilPDF plugin for Bubble is coming; until then, the API Connector does the same job and takes about ten minutes to set up.

#What you need

  • A Bubble app with the API Connector plugin installed.
  • A DevilPDF API key. Sign up, open API keys and create one. It starts with dp_live_. The free plan includes 500 documents a month.
  • In your database: an Invoice type with number (text), customer name (text), items (list of Line item) and pdf url (text). Line item has name (text), quantity (number) and price (number).

#1. Set up the API call

Follow the Bubble section of the integrations docs to add a DevilPDF API in the API Connector and a call that posts to https://devilpdf.com/v1/render. The short version:

  • Authentication: Private key in header, key name Authorization, value Bearer dp_live_....
  • Shared header Content-Type: application/json.
  • One call, used as an Action, with this body:
Body
{
  "template": "invoice",
  "data": {
    "number": <invoice_number>,
    "customer": { "name": <customer_name> },
    "items": <items_json>
  }
}

The text parameters have no quotes around them in the body, because you will pass them through :formatted as JSON-safe, which adds its own. Initialize the call with test values that are already valid JSON, for example "INV-1001" (with the quotes), "Acme Ltd" and [{"name": "Widget", "quantity": 2, "unit_price": 50}]. Bubble learns the response fields, including url.

Keep the key Private. Bubble then sends it from its own server and never to the visitor's browser.

#2. Build the items list from your database

items_json must be a JSON array. Build it from the invoice's line items with :format as text:

  • Content to show per list item: {"name": This Line item's name:formatted as JSON-safe, "quantity": This Line item's quantity, "unit_price": This Line item's price}
  • Delimiter: ,

Wrap the result in square brackets when you pass it: [ + Current Invoice's items:format as text + ].

:formatted as JSON-safe adds its own quotes and escapes characters such as quotation marks in product names, so do not add quotes around it. Numbers go in without quotes.

#3. The workflow

On your invoice page, add a Create PDF button and give it this workflow:

  1. Plugins → DevilPDF - Render (or whatever you named the call). Set invoice_number to Current page Invoice's number:formatted as JSON-safe, customer_name to Current page Invoice's customer name:formatted as JSON-safe, and items_json as built in step 2.
  2. Make changes to a thing → Current page Invoice: set pdf url to Result of step 1's url.
  3. Open an external website: Result of step 1's url, to show the PDF.

DevilPDF's hosted links expire: after 24 hours on the free plan, up to 30 days on paid plans. Until then you can get a fresh link at any time with GET /v1/documents/:id. If the PDF must be kept for good, store a copy in your own file storage; the docs cover the options.

You do not send totals. The invoice template adds up quantity × unit_price, applies any discount and tax_rate you send, and prints the subtotal, tax and total.

#Common errors

MessageFix
That API key is not validThe key value must be Bearer , a space, then the key.
The request body is not valid JSONA text value contains a quote or line break. Use :formatted as JSON-safe.
Initialize call times outRetry, or initialize with the invoice template and a short test body first.

#Other documents and languages

Change "template" to receipt, quote, statement, packing-slip, report or certificate to make other documents from the same kind of data. Add "locale": "<locale>" to the body and pass the user's language (fr, es, ar, ja...) to get translated labels and local date and money formats. Arabic and Hebrew documents mirror right to left.

#Next steps