> For the complete documentation index, see [llms.txt](https://docs.limio.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.limio.com/salesforce/setting-up/additional-config/apex-classes/generate-pdf-from-flow.md).

# Generate PDFs from Flow

#### **LFS version:** requires Limio for Salesforce v14.27 or later

Two invocable actions let a flow render a Salesforce email template as a PDF and attach it to a record. Both appear in Flow Builder under the **Limio For Salesforce** category. Use them in this order: generate the document, then store it.

## Generate PDF from Email Template

Renders an email template against a record and returns a base64 encoded PDF.

| Input          | Required | Purpose                                                                                       |
| -------------- | -------- | --------------------------------------------------------------------------------------------- |
| Email template | Yes      | Template Id or DeveloperName. Classic, Lightning and Visualforce templates all work.          |
| Record Id      | No       | The record that supplies the object merge fields, such as the Limio Quote or the Opportunity. |
| Data JSON      | No       | JSON that supplies the template tokens, for example the value of a JSON field on the record.  |

| Output                    | Purpose                                                |
| ------------------------- | ------------------------------------------------------ |
| Success                   | Whether the render succeeded.                          |
| Error message             | The reason for a failure.                              |
| File name                 | The generated file name.                               |
| Document content (base64) | The PDF itself. Pass this to Store PDF Against Record. |

## Store PDF Against Record

Stores a base64 encoded PDF as a Salesforce file, linked to a record.

| Input                     | Required | Purpose                                                                                                                             |
| ------------------------- | -------- | ----------------------------------------------------------------------------------------------------------------------------------- |
| Document content (base64) | Yes      | The output of Generate PDF from Email Template.                                                                                     |
| File name                 | Yes      | The file name to store, including the `.pdf` extension.                                                                             |
| Link to record Id         | Yes      | The record that the file is linked to and visible from.                                                                             |
| Add as new version        | No       | When true, a file with the same name on the record gains a new version. When false, a second file is created. The default is false. |

| Output        | Purpose                      |
| ------------- | ---------------------------- |
| Success       | Whether the file was stored. |
| Error message | The reason for a failure.    |

The action removes special characters from the file name and keeps it to 80 characters. For example, `Quote #12345 — Acme.pdf` is stored as `Quote 12345 Acme.pdf`.

## Template tokens in Data JSON

In the template body, `data` is the reserved root of the JSON you supply.

| Token                                              | What it does                                                         |
| -------------------------------------------------- | -------------------------------------------------------------------- |
| `{{data[0].offer.name}}`                           | Reads one value.                                                     |
| `{{data.total ?? 'n/a'}}`                          | Falls back from left to right when a value is missing.               |
| `{{#each data}}...{{/each}}`                       | Repeats the markup between the tags. `{{this}}` is the current item. |
| `{{table data \| description:Item, quantity:Qty}}` | Renders a table. One nested level is allowed after a semicolon.      |

Wrap a column label in single quotes when it contains a comma, a semicolon or a colon.

## Limits

| Limit                                          | Value        |
| ---------------------------------------------- | ------------ |
| Size of one document                           | 1.5 MB       |
| Documents in one transaction                   | 25           |
| Total PDF size in one transaction              | About 1.7 MB |
| Rows in one `{{table}}` token                  | 500          |
| Rows in all `{{table}}` tokens of a document   | 2000         |
| Repeats in one `{{#each}}` loop                | 500          |
| Repeats in all `{{#each}}` loops of a document | 5000         |

When an action reaches a size or count limit, it returns `Success = false` and a message in **Error message**. The flow continues.

When a template reaches a row limit, the action returns `Success = true` with fewer rows. A `{{table}}` token adds the row "N further rows were omitted because the row limit was reached." A `{{#each}}` loop shows no message. Check the PDF before you send it to a customer.

{% hint style="warning" %}
Add a decision element on **Success** after each action, and send the flow to an error path when the value is `false`.
{% endhint %}

## Repeat runs

When the flow can run more than once for the same record, set **Add as new version** to true. Each run then adds a version to the same file, and the earlier versions stay in the version history. With the default of false, each run stores a separate file.

## Permissions

The **Assisted Sales - Admin** and **Assisted Sales - User** permission sets give access to these actions. If your org uses a cloned permission set, add access to the Apex classes `GeneratePdfFromEmailTemplate`, `PdfGeneratorService` and `StorePdfDocument`. See [Permission Sets](/salesforce/setting-up/detailed-salesforce-setup/permission-sets-overview.md).

The Limio Quote record page has a **Related Documents** tab from v14.27. Stored files appear there.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.limio.com/salesforce/setting-up/additional-config/apex-classes/generate-pdf-from-flow.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
