Skip to main content

A PDF viewer for nicegui based on pdf.js

Project description

nicegui-pdf

A NiceGUI PDF component (using pdf.js) to nicely integrate PDFs without the need for iframes without having any control on which page is shown or without the possibility to read the seelcted text. Install with

pip install nicegui-pdf

A quick example on how to use the component is given next:

from nicegui import ui, app
from nicegui_pdf import PdfViewer

# [...] 

state = {
    "current_page": 1,
}

# [...]

ui.number().bind_value(state, "current_page")

path = app.add_static_file(local_file="example/paper.pdf")
PdfViewer(path).classes("w-full").style(
    "border: solid 1px gray;"
).bind_current_page(
    state
)

Features

  • Full integration of PDF files into NiceGUI
  • Two-way binding of current_page
  • One-way binidng of num_pages, is_rendering and selected_text

A full example demonstrating all features is given in example/main.py:

table

ToDo's

  • Integrate pdf.js and add a basic PDF viewer
  • Bind current page
  • Implement text overlay for selected text
  • Bind to selected text
  • Bind number of pages
  • Binding for is rendering
  • Resize PDF on window resize
  • Bind path (load new pdf document)

Optional

  • Highlight text
  • Show outline

Disclaimer

I'm neither a JS, NiceGUI or VUE expert. I simply tested a few things and found that an older version of PDF.js can be integrated as a custom NiceGUI component. Therefore, I cannot give any warranty etc. but still I'm trying to maintain this code. If you find any bugs or have feature requests, please open an issue or a pull request.

Donate

If you like it and want to buy me a coffee:

Thank you so much!

References

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

nicegui_pdf-0.0.7.tar.gz (408.5 kB view details)

Uploaded Source

Built Distribution

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

nicegui_pdf-0.0.7-py3-none-any.whl (411.0 kB view details)

Uploaded Python 3

File details

Details for the file nicegui_pdf-0.0.7.tar.gz.

File metadata

  • Download URL: nicegui_pdf-0.0.7.tar.gz
  • Upload date:
  • Size: 408.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.11

File hashes

Hashes for nicegui_pdf-0.0.7.tar.gz
Algorithm Hash digest
SHA256 5e80d9f8c4ca3c9809382b7fddf45072a0a642efc305eaf1aebafa3f2131101c
MD5 b76cdb0d25e325c7afd3901393c8bbeb
BLAKE2b-256 a8ea5e16e1d20c82bc45d4dd16beccc5ef456ca216d24d9d185083278a7d3ea2

See more details on using hashes here.

File details

Details for the file nicegui_pdf-0.0.7-py3-none-any.whl.

File metadata

  • Download URL: nicegui_pdf-0.0.7-py3-none-any.whl
  • Upload date:
  • Size: 411.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.11

File hashes

Hashes for nicegui_pdf-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 62d584a6bb763ce1ecbe0de22feb878269f75172a6f508e8a4bc1f4e19256571
MD5 4dd6132656d44b3397ba6af637bdc4a9
BLAKE2b-256 415f23ab499f9fb2b48d00604bd43c150230b4ce1fe71e22dd8d6c471f2a523f

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