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.
Link response
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.
- 50 MB. Bubble rejects API Connector responses over 50 MB with "response too large" (hard limits). This only matters for the file response.
- 19 MB of attachments. That is the total for one Send email action.
- 50 seconds. Bubble stops waiting for an API after about 50 seconds. A render on our side has 30 seconds, so a normal PDF fits easily.
- 20 MB request body. That is the cap on the HTML you send us.
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.
- Browser print. You can open a page and let the user "Print → Save as PDF". The result depends on the user's browser, includes page chrome, and can't run in a backend workflow.
- PDF plugins. Several marketplace plugins convert a page or a group to PDF in the browser. Many rasterize the screen into an image, so text isn't selectable and long content splits awkwardly.
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.
- Use inline
<style>with@page { size: A4; margin: 18mm; }and send"prefer_css_page_size": true. - Add
break-inside: avoidon table rows and totals so they don't split across pages. - Reference images and fonts by absolute
https://URLs. Bubble file links often start with//and no scheme, so typehttps:in front of the dynamic image URL. - Escape user-entered text before inserting it into HTML.
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.
format: A3 to A6, Letter, Legal, Tabloid. Uselandscape: truefor wide tables.header_html/footer_htmlwithpageNumberandtotalPagesfor "Page 1 of 3".max_pagesto cap cost on unexpectedly long documents. A render over the limit fails and costs nothing.filenamesets the name in the response headers.
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.
Should I use the file response or the link response?
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.
