A Dash component library for rendering PDF documents with enhanced features.
Project description
Dash PDF Plus
Display and annotate PDFs in your Dash apps with enhanced features.
Features
- PDF Display: Render PDF documents directly in your Dash applications
- Interactive Annotations: Add comments, highlights, and rectangle annotations
- Navigation Controls: Navigate through PDF pages with built-in controls
- URL Loading: Load PDFs from URLs or local files
- Customizable UI: Customize button and control styling
Installation
pip install dash-pdf-plus
Usage
Basic PDF Display
import requests
from dash import Dash, html
import dash_pdf_plus
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_plus.DashPDF(
id="pdf-viewer",
data=pdf_bytes,
enableAnnotations=True,
selectedAnnotationTool="none",
annotations=[],
),
]
)
if __name__ == "__main__":
app.run(debug=True)
Advanced Usage with Annotations
The demo application (demo/app.py) showcases advanced features including:
- Annotation Tools: Comment, rectangle, and highlight tools
- Interactive Controls: Load PDFs from URLs, navigate pages
- Real-time Updates: Handle annotation changes with callbacks
- Responsive Design: Bootstrap-based UI with resizable panels
Key features demonstrated:
- PDF loading from URLs
- Annotation tool selection (comment, rectangle, highlight, none)
- Page navigation controls
- Annotation change handling
- Responsive layout with control panel
Run Demo Locally
cd demo
uv venv
uv pip install -r requirements.txt
uv run app.py
Open: http://localhost:8050
Development Setup
# Install JavaScript dependencies
npm install
# Install Python package in editable mode
uv venv
uv pip install -e .
# Install other Python dependencies
uv pip install -r requirements.txt
uv pip install -r tests/requirements.txt
Development Workflow
# Build the component
npm run build
# Run the demo
uv run demo/app.py
Release Process
# Generate distribution files
npm run build
# rm -rf dist
uv build
# Test the artifact
uv pip install dash dist/dash_pdf_plus-0.0.1.tar.gz
uv run demo/app.py
# Upload to PyPI
uv pip install twine
twine upload dist/*
# Or with UV
uv publish
# Clean up
rm -rf dist
Credits
This project is derived from the original dash-pdf implementation by Ploomber Inc.. We extend our gratitude to the original authors for their foundational work that made this enhanced version possible.
License
See LICENSE file for details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dash_pdf_plus-0.0.1.tar.gz.
File metadata
- Download URL: dash_pdf_plus-0.0.1.tar.gz
- Upload date:
- Size: 811.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ea198607eed2d93997a4c0159a5f48d71cd59ac913a73c360c623e72a90d1d30
|
|
| MD5 |
89b8bd2f595e54e72fbd6390b5bbc46c
|
|
| BLAKE2b-256 |
1635e2dfd9fc5e174e907d9df3bbd99e5bb89179b903fc018d13365b231e9eec
|
File details
Details for the file dash_pdf_plus-0.0.1-py3-none-any.whl.
File metadata
- Download URL: dash_pdf_plus-0.0.1-py3-none-any.whl
- Upload date:
- Size: 814.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2b8a78d579a48dab6dbe7399409e73037729c843a29e06a97dbeb9f3b9ef6353
|
|
| MD5 |
436791247c247e92ed34b7e02cdb1b30
|
|
| BLAKE2b-256 |
28200e167b7e8da7042e801c74c15f3eabbed52e9ad3f0ececa712557b3da863
|