> For the complete documentation index, see [llms.txt](https://docs.avonnicomponents.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.avonnicomponents.com/dynamic-components/components/pdf-viewer.md). Agents can also search and read this documentation through its [MCP server](https://docs.avonnicomponents.com/~gitbook/mcp).

# PDF Viewer

Display PDFs in a Dynamic Component from Salesforce Files, URLs or Base64 content, plus the Salesforce setting needed to view them inline.

## Overview

The PDF Viewer shows a PDF inside your Dynamic Component, so users read it on the page instead of downloading it. An account executive opens the signed contract from the Opportunity. A service agent reads the warranty terms on the Case.

The PDF can come from Salesforce Files (a ContentDocumentId), from a URL, or from Base64 content. When there is nothing to show yet, the viewer can display a placeholder instead of an empty frame.

## Tutorials

Step-by-step guides for the most common PDF Viewer jobs are collected in [PDF Viewer tutorials](https://docs.avonnicomponents.com/dynamic-components/tutorials/components/pdf-viewer.md).

<table data-view="cards"><thead><tr><th></th><th></th><th data-hidden data-card-cover data-type="files"></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>Show the Latest Contract on an Opportunity</strong></td><td>Open the most recent contract PDF attached to an Opportunity right on its record page, found by a Flow each time the page loads.</td><td><a href="https://2532358799-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FODPvvv7Cx9Z9RECLn3oV%2Fuploads%2FZsaZ8rxVE5kWwBgFO4Zf%2Fpdf-viewer-cover-latest-contract.png?alt=media">pdf-viewer-cover-latest-contract.png</a></td><td><a href="https://docs.avonnicomponents.com/dynamic-components/tutorials/components/pdf-viewer/show-the-latest-contract-on-an-opportunity.md">Show the Latest Contract on an Opportunity</a></td></tr><tr><td><strong>Pick a PDF from a List and Read It</strong></td><td>List every PDF attached to an Opportunity and open the one a user clicks in a viewer beside the list, without leaving the record page.</td><td><a href="https://2532358799-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FODPvvv7Cx9Z9RECLn3oV%2Fuploads%2F3A3nMmgyUwPD6Q1iJod5%2Fpdf-viewer-cover-pick-a-pdf.png?alt=media">pdf-viewer-cover-pick-a-pdf.png</a></td><td><a href="https://docs.avonnicomponents.com/dynamic-components/tutorials/components/pdf-viewer/pick-a-pdf-from-a-list.md">Pick a PDF from a List and Read It</a></td></tr><tr><td><strong>Show a Placeholder When No PDF Is Attached</strong></td><td>Show a clear message and an illustration when a record has no PDF yet, so users know the contract is missing instead of staring at an empty frame.</td><td><a href="https://2532358799-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FODPvvv7Cx9Z9RECLn3oV%2Fuploads%2FHX05a83GDAMRmrTFeu1k%2Fpdf-viewer-cover-placeholder.png?alt=media">pdf-viewer-cover-placeholder.png</a></td><td><a href="https://docs.avonnicomponents.com/dynamic-components/tutorials/components/pdf-viewer/show-a-placeholder-when-no-pdf.md">Show a Placeholder When No PDF Is Attached</a></td></tr><tr><td><strong>Show a PDF from a URL on a Record</strong></td><td>Display a PDF whose address is stored on a record field, and fix a blank viewer with a checklist of the settings and source formats to verify.</td><td><a href="https://2532358799-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FODPvvv7Cx9Z9RECLn3oV%2Fuploads%2F38Y0WKwFAZYYrvy3CUcT%2Fpdf-viewer-cover-pdf-from-url.png?alt=media">pdf-viewer-cover-pdf-from-url.png</a></td><td><a href="https://docs.avonnicomponents.com/dynamic-components/tutorials/components/pdf-viewer/show-a-pdf-from-a-url.md">Show a PDF from a URL on a Record</a></td></tr></tbody></table>

## Projects

See how PDF Viewer fits into a complete Salesforce workflow. Each project includes steps to build it with AI or manually.

<table data-view="cards"><thead><tr><th></th><th></th><th data-hidden data-card-cover data-type="image">Cover image</th></tr></thead><tbody><tr><td><h4><a href="https://docs.avonnicomponents.com/projects/use-cases/record-pages/account-pdf-viewer">Account PDF Viewer</a></h4></td><td>Use Dynamic Components and Flow to create a reactive PDF viewer without code.</td><td data-object-fit="fill"><a href="https://3857391697-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdHOej9Pd5IxJNGEJMZKW%2Fuploads%2Feer8G4sH3b6Y4fgHUMBs%2Faccount-pdf-viewer-cover.png?alt=media">https://3857391697-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FdHOej9Pd5IxJNGEJMZKW%2Fuploads%2Feer8G4sH3b6Y4fgHUMBs%2Faccount-pdf-viewer-cover.png?alt=media</a></td></tr></tbody></table>

## Configuration

Select the PDF Viewer on the canvas. The **Edit Pdf Viewer** panel opens on the right, with a **Properties** tab and a **Style** tab. The PDF Viewer has no interactions and no output variables.

<figure><img src="https://2532358799-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FODPvvv7Cx9Z9RECLn3oV%2Fuploads%2FxJLrRDg1asDxBt9PN0jf%2Fpdf-viewer-pdf-viewer-properties.png?alt=media" alt="Edit Pdf Viewer panel, Properties tab, with Source bound to Contract File Id, the Title and the Placeholder section open" width="320"><figcaption><p>Source holds the contractFileId variable; the Placeholder section shows its three settings.</p></figcaption></figure>

### Properties

| Setting    | Description                                                                                                                                                                                              | Example                   |
| ---------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------- |
| **Source** | The PDF to display. Accepts a ContentDocumentId, a URL, or Base64 content: see [Source formats](#source-formats) below. Bind it to a variable, a formula or a record field to change the PDF per record. | `{!contractFileId}`       |
| **Title**  | The accessible name of the viewer frame, read by screen readers. It is not printed on the page: to show a heading above the PDF, add a **Text** or a **Header** component.                               | `Signed service contract` |

#### Source formats

The viewer reads **Source** and recognizes four formats. Any other value leaves the frame blank, without an error message.

| Format            | What to enter                                                                         | Notes                                                                                                                                                                                |
| ----------------- | ------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| ContentDocumentId | The 15 or 18 character Id of a Salesforce File, starting with `069`                   | The viewer turns it into the file's download address in your org. A ContentVersion Id (starting with `068`) is not recognized: use the **Content Document ID** field of the version. |
| Absolute URL      | An address starting with `https://` (or `http://`)                                    | Use `https://`: browsers block an `http://` PDF inside a Salesforce page. The site must allow its PDFs to be shown in a frame.                                                       |
| Relative path     | A path on your Salesforce domain starting with `/`                                    | For example `/sfc/servlet.shepherd/document/download/069...?operationContext=S1`.                                                                                                    |
| Base64            | The full data address: `data:application/pdf;base64,` followed by the encoded content | Raw Base64 without that prefix is not recognized. Keep it for small generated PDFs: a long string weighs on the page.                                                                |

{% hint style="warning" %}
**Set PDFs to open in the browser**

For Salesforce Files, the viewer stays blank or downloads the file unless PDFs are allowed to open in the browser. In Setup, open **File Upload and Download Security**, click **Edit**, set the **.pdf** row to **Execute in Browser**, and save. Then reload the page.

<img src="https://2532358799-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FODPvvv7Cx9Z9RECLn3oV%2Fuploads%2Fgit-blob-a6ad81c6e170a559e3d5f6887f2eb50932b80dd7%2F2025-06-10_13-39-35.png?alt=media" alt="File Upload and Download Security in Setup, with the .pdf row set to Execute in Browser" data-size="original">
{% endhint %}

### Placeholder

The **Placeholder** section is collapsed by default. It replaces the empty frame with an illustration and a message.

| Setting                      | Description                                                                                                                               | Example / Options                                                                                                                                                                                                                                                                                                                                                                |
| ---------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Show Placeholder**         | Shows the placeholder when **Source** is empty. With a PDF in **Source**, the viewer shows the PDF, whatever this setting. (Default: off) | On                                                                                                                                                                                                                                                                                                                                                                               |
| **Placeholder Message**      | The text shown with the illustration. Requires **Show Placeholder** to be enabled.                                                        | `No signed contract yet.`                                                                                                                                                                                                                                                                                                                                                        |
| **Placeholder Illustration** | The picture shown above the message. Requires **Show Placeholder** to be enabled. (Default: **No Preview**)                               | **Text Only**, **No Content**, **No Preview**, **Preview**, **Research**, **No Access**, **No Access 2**, **No Connection**, **Page Not Available**, **Not Available In Lightning**, **Walkthrough Not Available**, **Setup**, **Maintenance**, **No Events**, **No Task**, **Going Camping**, **Gone Fishing**, **Fishing Deals**, **Desert**, **Open Road**, **Lake Mountain** |

The placeholder only appears for an empty **Source**. A value the viewer does not recognize (see [Source formats](#source-formats)) is not empty: the frame stays blank and the placeholder does not show.

### Set Component Visibility

All components support conditional visibility. See [Component Visibility](https://docs.avonnicomponents.com/dynamic-components/core-concepts/component-visibility.md).

## Use Cases

* The latest signed contract or invoice on an Opportunity.
* A list of a record's PDFs, with the one the user picks open beside it.
* A product datasheet held as a URL on a Product record.
* A warranty or policy document on a Case or an Asset.

## Add a PDF Viewer to a record page

{% stepper %}
{% step %}

### Set the target object

Open your Dynamic Component and set the **Target Page Object** to the object of the page, for example `Opportunity`. See [Target Page Object](https://docs.avonnicomponents.com/dynamic-components/core-concepts/target-page-object.md).
{% endstep %}

{% step %}

### Add the viewer and give it a source

Drag a **PDF Viewer** onto the canvas. Set **Source** to a ContentDocumentId, a URL, or a resource that holds one. The tutorials above show where that value usually comes from: a Flow run **On Load**, a list of the record's files, or a record field.
{% endstep %}

{% step %}

### Give the viewer room

The viewer is at least 300 pixels tall. To read a full page, open the **Style** tab and set **Height** in the **Size** section, for example `600` with the unit **px**.
{% endstep %}

{% step %}

### Save and test

Save the component, add it to the record page in Lightning App Builder, and open a record that has a PDF. If the frame stays blank, go through the checklist in [Show a PDF from a URL on a Record](https://docs.avonnicomponents.com/dynamic-components/tutorials/components/pdf-viewer/show-a-pdf-from-a-url.md).
{% endstep %}
{% endstepper %}

## Styling

Configure the PDF Viewer's appearance from the **Style** tab of the **Edit Pdf Viewer** panel.

{% tabs %}
{% tab title="Margin" %}
The space outside the viewer, set per side.
{% endtab %}

{% tab title="Padding" %}
The space between the viewer's edge and the PDF frame, set per side.
{% endtab %}

{% tab title="Size" %}

* **Width** and **Height**: the viewer's dimensions. Set a **Height** to show more of each page.
* **Overflow**: what happens to content that does not fit.
* Under **Advanced Options**: **Min Width**, **Max Width**, **Min Height**, **Max height**, **Overflow X** and **Overflow Y**.
  {% endtab %}

{% tab title="Border" %}
**Color**, **Size**, **Style** and **Radius** of the border around the viewer.
{% endtab %}
{% endtabs %}

## Troubleshooting Common Issues

* **The frame is blank.** Go through the blank viewer checklist in [Show a PDF from a URL on a Record](https://docs.avonnicomponents.com/dynamic-components/tutorials/components/pdf-viewer/show-a-pdf-from-a-url.md): file security setting, **Source** format, file access, and framing.
* **The placeholder never shows.** See [Placeholder](#placeholder) above: **Show Placeholder** must be on and **Source** truly empty.


---

# 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.avonnicomponents.com/dynamic-components/components/pdf-viewer.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.
