Skip to content

About

A PDF viewer for NiceGUI

Resources

Stars

17 stars

Watchers

1 watching

Forks

Latest commit

 

History

31 Commits

Folders and files

Repository files navigation

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

About

A PDF viewer for NiceGUI

Resources

Stars

17 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages