HTML to PDF in Bubble

HTML to PDF in Bubble

Generate PDFs in Bubble with the API Connector. Get the PDF back as a file saved in Bubble storage, or as a 24-hour link. Both options explained, with setup.

Bubble apps often need to hand users a document, such as an invoice, an order confirmation, a certificate or a gift voucher. Bubble has no built-in HTML-to-PDF action, so most apps use a plugin or call a PDF API through the API Connector.

This page explains the API Connector route and how to choose between the two response options. The click-by-click setup is in the Bubble guide.

Quick answer. In the API Connector, add a POST call to https://html-pdf.com/v1/pdf with the header Authorization: Bearer YOUR_API_KEY. Set the call's data type to File and send this JSON body. Bubble stores the PDF in your app's file storage and hands it to your workflow as a file.

{ "html": <html>, "format": "A4" }

Want a download link instead? Add "response": "url" and set the data type to JSON.

Two ways to get the PDF back

The same call can return the PDF in two shapes. Pick one per call.

File response (default) Link response
Body no response field "response": "url"
API Connector data type File JSON
What Bubble gets the PDF itself, saved to Bubble storage url, pages, credits_remaining, expires_at
Lifetime permanent, like any uploaded file the link expires after 24 hours
Best for file fields, email attachments, archives opening or sharing the PDF right away

File response

By default the API answers with the raw PDF bytes (application/pdf). With the API Connector's File data type, Bubble saves the whole response as a file in your app's storage and returns that file. Bubble's team explained this when they announced the option.

Choose this when the PDF must live in your database. Bubble's Send email action only attaches files stored in your app's Bubble storage, so this is also the way to email a PDF as an attachment.

With "response": "url" the API returns JSON instead.

{ "id": "cv_...", "pages": 1, "credits_used": 1, "credits_remaining": 99, "url": "https://html-pdf.com/f/...", "expires_at": "..." }

Choose this when you only need to open the PDF in a new tab or send a link, or when you want the page count and remaining credits in the same step. The link stops working after 24 hours, so don't store it as the permanent copy.

Limits to know

Bubble and html-pdf.com both have limits, and the smallest one wins.

Most PDFs are a few hundred KB. Big ones are almost always caused by large photos, and the guide shows how to keep PDFs small.

Native options and their limits

This section covers what you can do without an API, and why it falls short.

A server-side Chromium render avoids both problems. You get selectable text, real page breaks, headers and footers, and it works in backend workflows with no user on the page.

Building the HTML

These tips help your template print cleanly.

Keep your template in an option set, a text field, or a "template" thing, and fill in dynamic values with Bubble expressions. Then apply :formatted as JSON-safe to the whole expression when you pass it to the call. Bubble's operator wraps the text in quotes and escapes characters like " and line breaks, so the JSON stays valid.

Ready-made layouts are at https://html-pdf.com/templates, and a full invoice example is at https://html-pdf.com/generate-invoice-pdf.

Rendering a page by URL

You can also turn an existing page into a PDF instead of sending HTML.

Send "url": "https://..." in place of html. The page must be publicly reachable without login, so this suits public pages. For private data, pass HTML.

Use wait_delay or wait_for_expression if the page draws content with JavaScript after loading.

More options

These extra options cover most layout needs.

The full list is in the API reference.

FAQ

How do I create a PDF in Bubble?

Add a POST call to https://html-pdf.com/v1/pdf in the API Connector with your HTML as the body and your key in a private header. Use it as an action in a workflow. The Bubble guide walks through every field.

Can the Bubble API Connector return a PDF file?

Yes. Set the call's data type to File and leave out response. Bubble saves the returned PDF to your app's storage, and you can put it in a file field or attach it to an email.

Use the file response when you need to keep the PDF or attach it to an email. Use "response": "url" when a 24-hour download link is enough, for example to open the PDF in a new tab.

Why is my PDF so large?

Usually because of full-size photos in the HTML. Resize images before you insert them, and check the size limits above. One page with a few phone photos can reach tens of MB.

Is there a free plan?

You get 100 free credits once you confirm your email, with no card. One credit is one PDF page, failed renders are free, and purchased credits never expire.

This page as markdown · text