> For the complete documentation index, see [llms.txt](https://docs.eximee.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.eximee.com/documentation/documentation-en/budowanie-aplikacji/interfejs-uzytkownika/formularze/biblioteka-komponentow-bazowych/5-dokumenty-i-zaloczniki/podglad-pdf-pdfviewer.md). Agents can also search and read this documentation through its [MCP server](https://docs.eximee.com/~gitbook/mcp).

# PDF preview - PdfViewer

{% hint style="info" %}
The availability of the functionality depends on the license and may not be available in all deployments.
{% endhint %}

The component allows a PDF document to be displayed directly on the form. The document can be specified by a URL (a path to a file available in the environment or an address of an external resource) or by a document identifier in an external source from which the platform fetches the document server-side. This allows the user to review the content (e.g. terms and conditions, an agreement, or instructions) without having to download the file to disk or open a new browser tab.

![](https://2112972046-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2CssJT0zIo4SJQLbSZ6l%2Fuploads%2Fgit-blob-51026b7b518a157ff219cd1c7b23a1cde66e09cd%2FpdfViewer5.png?alt=media)

✅ **When to use:**

* Displaying a single PDF document directly on the form.

:x: **When not to use:**

* Presenting a list of documents or enabling their download. Use: [DocumentList](https://docs.eximee.com/documentation/documentation-en/budowanie-aplikacji/interfejs-uzytkownika/formularze/biblioteka-komponentow-bazowych/5-dokumenty-i-zaloczniki/lista-dokumentow-documentlist.md).
* Providing the user with a link to a document or another resource without displaying its content on the form. Use: [ExternalLink](https://docs.eximee.com/documentation/documentation-en/budowanie-aplikacji/interfejs-uzytkownika/formularze/biblioteka-komponentow-bazowych/0-struktura-i-nawigacja/nawigacja/link-externallink.md).

## PDF viewer component

![Figure 1. Example appearance of the component on the form](https://content.gitbook.com/content/2CssJT0zIo4SJQLbSZ6l/blobs/5huZzcoz1hG3JYZMcugp/18k_files/image2025-5-23_8-38-27.png)

### Component properties

| Eximee Designer properties                                                                          | Attribute name in Source | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| --------------------------------------------------------------------------------------------------- | ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| <p><strong>Document source</strong><br>(section <strong>Basic properties</strong>)</p>              | documentSource           | <p>Specifies where the component fetches the document from: <strong>Direct URL</strong> (default) means the address from the field <strong>PDF link</strong>, and each subsequent option is an external source configured in the installation, from which the document is fetched by the identifier from the field <strong>Document identifier</strong>.</p><p>When <strong>Direct URL</strong> is selected, the attribute is not saved in Source.</p><p>The field is visible only if at least one external source has been configured in the installation (see section <strong>Document from an external source</strong>).</p>                                                                                                                                                                                                |
| <p><strong>Document identifier</strong><br>(section <strong>Basic properties</strong>)</p>          | externalDocumentId       | <p>Identifier of the document in the source selected in the field <strong>Document source</strong>. It may contain a reference to a session variable, e.g. <code>${documentId}</code>.</p><p>The field is visible when an external source is selected in the field <strong>Document source</strong> .</p><p>An empty identifier does not cause an error: the component displays nothing and the application continues.</p>                                                                                                                                                                                                                                                                                                                                                                                                     |
| <p><strong>PDF link</strong><br>(section <strong>Basic properties</strong>)</p>                     | pdfUrl                   | <p>A relative path to a file placed in a folder in the application environment, or an external link, but in that case it must meet CORS policy requirements (the Access-Control-Allow-Origin header must be set correctly).</p><p>By default, the property is empty.</p><p><strong>Important:</strong> Entering an invalid URL or not entering one at all causes an error and prevents the application from being completed after attempting to display the PDF file.</p><p>The field is visible when an external source is selected in the field <strong>Document source</strong> selected <strong>Direct URL</strong>. After selecting an external source, the field is hidden, and the entered address remains in the component definition and appears again after returning to the option <strong>Direct URL</strong>.</p> |
| <p><strong>Document window height - desktop (vh)</strong><br>(section <strong>Styling</strong>)</p> | desktopHeight            | <p>Document window height on desktop and tablet as a percentage of the browser window height (vh unit), from 0 to 100.</p><p>Default is 0, meaning the height defined in the theme.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| <p><strong>Document window height - mobile (vh)</strong><br>(section <strong>Styling</strong>)</p>  | mobileHeight             | <p>Document window height on a phone as a percentage of the browser window height (vh unit), from 0 to 100.</p><p>Default is 0, meaning the height defined in the theme.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |

> More information about component properties: [Common component properties](https://docs.eximee.com/documentation/documentation-en/budowanie-aplikacji/interfejs-uzytkownika/formularze/praca-z-komponentami-bazowymi/wspolne-wlasciwosci-komponentow.md)

### Document from URL

When in the field **Document source** is selected **Direct URL** (or the field is not visible because no external sources are configured in the installation), configure the PDF file address in the field **PDF link** in the component properties panel. This value can be entered directly as a static link or passed dynamically using a variable.

1. Path to a file available in the environment

   This involves providing the path to a static resource placed directly in the application server's directory structure.

   ![Figure 2. Component configuration using a local path](https://2112972046-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2CssJT0zIo4SJQLbSZ6l%2Fuploads%2Fgit-blob-e606274a42a7c2c9afe1f45c1056b2285fcb3477%2FpdfViewer.png?alt=media)
2. External URL

   This involves providing an absolute URL to the file. However, the external server must allow the browser to download the file from the application in accordance with CORS policy.

   ![Figure 3. Component configuration using an external URL](https://2112972046-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2CssJT0zIo4SJQLbSZ6l%2Fuploads%2Fgit-blob-5be1fb09d37bc07df07540326db191f4b3b0e466%2FpdfViewer3.png?alt=media)

{% hint style="info" %}
CORS is a security mechanism in web browsers. It blocks fetching resources (e.g. PDF files) from a domain other than the one where the form is located, unless the target server explicitly allows it by sending the appropriate HTTP header (`Access-Control-Allow-Origin`).
{% endhint %}

3. Feeding the component with a session variable value

   The PDF file address can be dynamically fed with the value of a session variable. In the field `PDF link` you can use a reference to a variable (e.g. `${pdfUrl}`), which will be fed with a value coming from a script or service.

   ![Figure 4. Component configuration using a session variable](https://2112972046-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2CssJT0zIo4SJQLbSZ6l%2Fuploads%2Fgit-blob-8849b1aec658b56fb59541f6a75ee8391b023275%2FpdfViewer2.png?alt=media)

   ![Figure 5. Session variable fed with a value from a script](https://2112972046-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2CssJT0zIo4SJQLbSZ6l%2Fuploads%2Fgit-blob-7c87458adf9b215317618b6009c805c1ca4d9c00%2FpdfViewer4.png?alt=media)

{% hint style="info" %}
When feeding the component with a session variable, remember to add a listener for that variable.
{% endhint %}

{% hint style="info" %}
Remember that the value of the session variable used in the field `PDF link` cannot be empty — otherwise the application will not work correctly after attempting to display the component.
{% endhint %}

### Document from an external source

An external source is a system where documents are stored, for example an organization's document repository. You identify the document by the identifier it has in that source, and the platform fetches it server-side via the integration with the source available in the installation.

To display a document from an external source:

1. Select the component and, in the properties panel, in the section **Basic properties**, in the field **Document source** select the source.
2. In the field **Document identifier** enter the document identifier directly or as a reference to a session variable, e.g. `${documentId}`.
3. If the identifier comes from a session variable, in the section **Interactions** in the field **Listeners** add that variable. Without a listener, the component may be displayed before the variable gets a value and will not refresh after it is set. More in: [Listening and clearing](https://docs.eximee.com/documentation/documentation-en/budowanie-aplikacji/interfejs-uzytkownika/formularze/dynamicznosc-formularza/nasluchiwanie-i-czyszczenie.md).

Example: the page service generates a document, saves it in an external source, and returns its identifier. The service result feeds the session variable `documentId`, and the component is set to:

* **Document source**: the source where the service saved the document,
* **Document identifier**: `${documentId}`,
* **Listeners**: `documentId`.

After entering the page, the component displays the generated document. In the application Source, the component looks as follows (`documentRepository` is an example source name):

```xml
<p1:GesPdfViewer id="GesPdfViewer1" mid="GesPdfViewer1" documentSource="repozytoriumDokumentow" externalDocumentId="${documentId}">
```

Component behavior with an external source:

* The document is fetched from the source each time it is displayed and is not stored by the platform.
* The document identifier is not passed to the browser. The browser receives only a link to the current document of the component, so it cannot use it to fetch another document from the source.
* After the identifier changes, for example when the session variable is assigned a new value, the component loads the new document.
* When the identifier is empty, the component displays nothing and does not fetch a document, and the application continues. The document appears when the identifier gets a value.
* A source error, no document in the source, or selecting a source with which the installation has no integration takes the application to the error page, just like an invalid URL.
* CORS policy requirements do not apply to a document from an external source, because the browser fetches it from the application's server.

{% hint style="info" %}
The list of sources in the field **Document source** is defined by the Designer configuration: the key `eximee.console.pdf-viewer.document-sources` contains source names separated by commas. The environment can override this list with the environment variable `EXIMEE_CONSOLE_PDF_VIEWER_DOCUMENT_SOURCES`. When the list is empty, the fields **Document source** and **Document identifier** are hidden. The source works only in an installation where integration with that source is available.

```properties
eximee.console.pdf-viewer.document-sources=documentRepository
```

{% endhint %}

### Document window height

By default, the document window has the height defined in the theme. To set a different height for a single component, in the properties panel, in the section **Styling**, enter a value in the field **Document window height - desktop (vh)**, **Document window height - mobile (vh)** or in both.

* The value is a percentage of the browser window height (vh unit), from 0 to 100. A value of 0 means the height from the theme.
* The field shows 0 until you set a height. Clearing the field saves 0.
* A value outside the range is rejected with a message, and the field returns to the previous value.
* A height set for only one device type does not change the other.
* Mobile height is used when the application is opened on a phone. The phone is recognized by the browser, and desktop and tablet use the desktop height. The browser window width does not change this selection, so simply narrowing the window does not switch the component to mobile height. To check the mobile height on a computer, enable phone emulation in the browser's developer tools and reload the application page.

Example: the document window occupies 60% of the browser window height on desktop and 80% on a phone.

1. In the field **Document window height - desktop (vh)** enter `60`.
2. In the field **Document window height - mobile (vh)** enter `80`.

In the application Source, the component looks as follows:

```xml
<p1:GesPdfViewer id="GesPdfViewer1" mid="GesPdfViewer1" pdfUrl="dokumenty/regulamin.pdf" desktopHeight="60" mobileHeight="80">
```

{% hint style="info" %}
Demo applications: demoPdfViewer
{% endhint %}


---

# 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.eximee.com/documentation/documentation-en/budowanie-aplikacji/interfejs-uzytkownika/formularze/biblioteka-komponentow-bazowych/5-dokumenty-i-zaloczniki/podglad-pdf-pdfviewer.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.
