Skip to main content

Dash PDF

Display PDFs in your Dash apps.


Ploomber Logo
Made by Ploomber with ❤️

Deploy your Dash application on Ploomber.io for free.


https://github.com/user-attachments/assets/bcc9ba7d-5110-4fb9-ba58-551684890ae9

Live demo: dash-pdf.ploomberapp.io

Installation

pip install dash-pdf

Usage

from dash import Dash, html
import dash_pdf
import requests
from pathlib import Path
import dash

dash._dash_renderer._set_react_version("18.2.0")

app = Dash(__name__)

# Download the PDF and read it as bytes
url = 'https://css4.pub/2015/textbook/somatosensory.pdf'
response = requests.get(url)
pdf_bytes = response.content

# Alternatively, you can read a local PDF file
# pdf_bytes = Path('path/to/local/file.pdf').read_bytes()

app.layout = html.Div([
    dash_pdf.PDF(
        id='pdf-viewer',
        # Pass the PDF content as bytes, you can also pass a URL
        data=pdf_bytes,
        # use these to customize the class names
        buttonClassName="",
        labelClassName="",
        controlsClassName="",
    )
])

if __name__ == '__main__':
    app.run_server(debug=True)

Run demo locally

cd demo
pip install -r requirements.txt
python app.py

Open: http://localhost:8050

Documentation

Setup

# install js dependencies
npm install
# install python package in editable mode
pip install -e .

# install other python dependencies
pip install -r requirements.txt
pip install -r tests/requirements.txt

Development

npm run build
python demo.py

Release

# generate
npm run build
python setup.py sdist bdist_wheel
ls dist

# test artifact
pip install dash dist/dash_pdf-0.0.1.tar.gz
python demo/app.py

# upload
pip install twine
twine upload dist/*

# clean up
rm -rf dist

Metadata

Release files for dash-pdf 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dash-pdf 0.0.1
File Size Uploaded
dash_pdf-0.0.1.tar.gz 399.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dash-pdf 0.0.1
File Interpreter ABI Platform
dash_pdf-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 801.0 kB

Release files / dash_pdf-0.0.1.tar.gz

Download URL dash_pdf-0.0.1.tar.gz
Size 399.0 kB
Tags Source
SHA-256 checksum
How to use checksums
94e9de3ef1e3560919bf1e306405c5c9c649ed482fd1b7b8e5fdfa226fa79400
BLAKE2b-256 checksum
How to use checksums
d921a71d6af431a39b68d1e767507cbadf52d283878bfc657152b20b58db5139
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.11.10

Release files / dash_pdf-0.0.1-py3-none-any.whl

Download URL dash_pdf-0.0.1-py3-none-any.whl
Size 402.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a776e5e0828e1622b55a78cd4c1bedbb2ba7f2f6dc059cf64cbac7d7710d151c
BLAKE2b-256 checksum
How to use checksums
a3f68d899df76ad55517cc51c8f24a6d4e46f66097b35c7a3948deaa1412df28
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.11.10

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page