Skip to main content

Reflex custom component pdf-viewer

Project description

Reflex PDF Viewer

A powerful and easy-to-use PDF viewer component for Reflex applications. Built on top of react-pdf, it provides seamless PDF viewing capabilities with full control over navigation, zoom, and display options.

📦 Installation

pip install reflex-pdf-viewer

🚀 Quick Start

import reflex as rx
from reflex_pdf_viewer import Document, Page

class State(rx.State):
    current_page: int = 1
    n_pages: int = 1

    @rx.event
    def load_success(self, info: dict):
        self.n_pages = info.get("numPages", 1)

def index():
    return rx.vstack(
        rx.heading("Reflex pdf preview", size="8"),
        Document.create(
            Page.create(page_number=State.current_page),
            file="https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf",
            on_load_success=State.load_success,
        ),
    )

app = rx.App()
app.add_page(index)

Don't forget to add the frontend package to your rxconfig.py:

import reflex as rx

config = rx.Config(
    app_name="your_app",
    frontend_packages=[
        "react-pdf@10.1.0",  # Required for PDF viewing
    ],
)

📝 Changelog

v0.0.1 (2024-12-09)

  • Initial release
  • Basic PDF viewing functionality
  • Page navigation support
  • Zoom controls
  • Error handling
  • Loading states

🐛 Issues & Support

If you encounter any issues or have questions:

  1. Check the GitHub Issues
  2. Join the Reflex Discord community
  3. Create a new issue with detailed information

🙏 Acknowledgments

  • Built with Reflex - The web framework for Python
  • Powered by react-pdf - React PDF viewer component
  • Uses PDF.js - JavaScript PDF rendering engine

Made with ❤️ for the Reflex community

Star ⭐ this repo if you find it useful!

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

reflex_pdf_viewer-0.0.2.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

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

reflex_pdf_viewer-0.0.2-py3-none-any.whl (3.3 kB view details)

Uploaded Python 3

File details

Details for the file reflex_pdf_viewer-0.0.2.tar.gz.

File metadata

  • Download URL: reflex_pdf_viewer-0.0.2.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.0

File hashes

Hashes for reflex_pdf_viewer-0.0.2.tar.gz
Algorithm Hash digest
SHA256 bdf58b033003ab6b7bd6a001c90500f4d6b688bbaf24ec7d6e3fa63c7008810c
MD5 8df38413888adea895a810171162f441
BLAKE2b-256 d62c7c1b9e20d384cd159ceb26b73f058e583c304f9de6494ec5e05b65e8e0e0

See more details on using hashes here.

File details

Details for the file reflex_pdf_viewer-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for reflex_pdf_viewer-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 188aca250f30b39e357d092598db7861288b219ddd404cbe9d666325b765ffe0
MD5 9918c0f42eca147247525d688e6249de
BLAKE2b-256 608250e9ac3b2fec587de88ebb249523ec6c626462d4209c4c46e34a6c973128

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