> ## Documentation Index
> Fetch the complete documentation index at: https://docs.chainlit.io/llms.txt
> Use this file to discover all available pages before exploring further.

# PDF viewer

The `Pdf` class allows you to display a PDF hosted remotely or locally in the chatbot UI. This class either takes a URL of a PDF hosted online, or the path of a local PDF.

<Note>
  Since version **2.11.0**, the PDF viewer uses a custom React-based renderer
  with zoom, pagination, download, and print controls instead of the browser's
  built-in iframe viewer. The `pdfjs-dist` worker is bundled locally — no
  external CDN requests are made. If you relied on the previous iframe behavior
  or applied custom CSS targeting the old viewer, you may need to update your
  styles.
</Note>

## Attributes

<ParamField path="name" type="str">
  The name of the PDF to be displayed in the UI.
</ParamField>

<ParamField path="display" type="ElementDisplay" optional>
  Determines how the PDF element should be displayed in the UI. Choices are
  "side", "inline", or "page".
</ParamField>

<ParamField path="url" type="str">
  The remote URL of the PDF file. Must provide url for a remote PDF (or either
  path or content for a local PDF).
</ParamField>

<ParamField path="path" type="str" optional>
  The local file path of the PDF. Must provide either path or content for a
  local PDF (or url for a remote PDF).
</ParamField>

<ParamField path="content" type="bytes" optional>
  The file content of the PDF in bytes format. Must provide either path or
  content for a local PDF (or url for a remote PDF).
</ParamField>

<ParamField path="page" type="int" optional>
  The default rendered page. Must be an integer greater than 0 and less than or
  equal to the total number of pages in the PDF. The default value is 1.
</ParamField>

## Example

### Inline

```python theme={null}
import chainlit as cl


@cl.on_chat_start
async def main():
    # Sending a pdf with the local file path
    elements = [
      cl.Pdf(name="pdf1", display="inline", path="./pdf1.pdf", page=1)
    ]

    await cl.Message(content="Look at this local pdf!", elements=elements).send()
```

### Side and Page

You must have the name of the pdf in the content of the message for the link to be created.

```python theme={null}
import chainlit as cl


@cl.on_chat_start
async def main():
    # Sending a pdf with the local file path
    elements = [
      cl.Pdf(name="pdf1", display="side", path="./pdf1.pdf", page=1)
    ]
    # Reminder: The name of the pdf must be in the content of the message
    await cl.Message(content="Look at this local pdf1!", elements=elements).send()
```
