Skip to main content

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,
            enable_annotations=True,
            selected_annotation_tool="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:8060

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
rm -rf dist
npm run build
uv build

# Test the artifact
uv pip install dash dist/dash_pdf_plus-0.0.3.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

dash_pdf_plus-0.0.4.tar.gz (820.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dash_pdf_plus-0.0.4-py3-none-any.whl (824.9 kB view details)

Uploaded Python 3

File details

Details for the file dash_pdf_plus-0.0.4.tar.gz.

File metadata

  • Download URL: dash_pdf_plus-0.0.4.tar.gz
  • Upload date:
  • Size: 820.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.5

File hashes

Hashes for dash_pdf_plus-0.0.4.tar.gz
Algorithm Hash digest
SHA256 f41517fbd2e2a0549c94bb3e7590ac237e1775407c25e6db4a941dbf91cc7c77
MD5 12cb78530d2aabf603acd1dbe32543a0
BLAKE2b-256 aab2c0adfeab7b73b3dcd732c3bd88320270c86dfc7d91bad056fcb266689ef6

See more details on using hashes here.

File details

Details for the file dash_pdf_plus-0.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for dash_pdf_plus-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 49e62b21fc89371e0bc22568f9c33f33f7616c3be6eeb5fea11acab536655f4f
MD5 a9ad401aca897ddfb04f5ff2bed89202
BLAKE2b-256 c6066f41c724a008b7dc5f35fee2b5951076722ed1baf13e3eb1106cb34cb8aa

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page