Skip to main content

Web UI for groupdocs-viewer-net — mount into FastAPI/Flask/Django, or run standalone.

Project description

UI for GroupDocs.Viewer for Python via .NET

PyPI Python

GroupDocs.Viewer UI

A web UI for groupdocs-viewer-net — view 170+ document and image formats in a browser. Mount inside an existing FastAPI / Flask / Django app, or run standalone via the bundled CLI.

The frontend is the same battle-tested Angular SPA from the GroupDocs.Viewer for .NET UI project, vendored into this package — one pip install and you're done.

Install

pip install groupdocs-viewer-net-ui

Optional cloud-storage / cache backends:

pip install "groupdocs-viewer-net-ui[s3]"      # S3FileStorage
pip install "groupdocs-viewer-net-ui[azure]"   # AzureBlobFileStorage
pip install "groupdocs-viewer-net-ui[redis]"   # RedisCache
pip install "groupdocs-viewer-net-ui[all]"

Run it

CLI (zero config)

groupdocs-viewer-ui serve --files ./documents --cache ./.viewer-cache
# → http://127.0.0.1:8080/viewer/

Docker

docker compose up
# Drop documents into ./documents on the host

In code

from groupdocs_viewer_ui import Config, create_app
from groupdocs_viewer_ui.cache.local import LocalFileCache
from groupdocs_viewer_ui.storage.local import LocalFileStorage
from groupdocs_viewer_ui.viewer.selfhost import SelfHostViewer

storage = LocalFileStorage("./Files")
app = create_app(
    Config(),
    storage=storage,
    cache=LocalFileCache("./Cache"),
    viewer=SelfHostViewer(storage=storage),
)
# Run with: uvicorn myapp:app

create_app() returns a Starlette ASGI app — mount it under FastAPI directly, or bridge to Flask/Django with a2wsgi. See examples/ for runnable patterns.

Configure

Config() accepts knobs for rendering mode, preload count, initial zoom, UI toggles (header, toolbar, thumbnails, search, print, etc.), localization, branding, and routing. See AGENTS.md for the full field reference.

Config(
    rendering_mode="html",        # or "image"
    preload_pages=3,
    initial_zoom="Fit Page",      # or "Fit Width", "Fit Height", "100%", "75%", etc.
    enable_thumbnails=True,
    ui_title="My Document Viewer",
    custom_css="<style>:root { --c-bg-brand: #0d9488; }</style>",
)

Storage backends

Built-in: LocalFileStorage, S3FileStorage ([s3] extra), AzureBlobFileStorage ([azure] extra). Implement the FileStorage protocol for anything else — three async methods. See examples/05_custom_storage/ for a SQLite-backed example.

Cache backends

Built-in: InMemoryCache, LocalFileCache, RedisCache ([redis] extra). When you supply both viewer and cache to create_app(), the viewer is auto-wrapped in a CachingViewer decorator — no manual composition required. Implement the FileCache protocol for custom backends. See examples/06_custom_cache/ for a TTL wrapper.

Authentication

from starlette.exceptions import HTTPException

async def require_session(request):
    if request.cookies.get("session") not in VALID_SESSIONS:
        raise HTTPException(status_code=401, detail="Login required")

app = create_app(..., auth_check=require_session)

The check runs before every /viewer-api/* request. /health, the SPA, and static assets are deliberately not guarded — wrap the whole app yourself if you need broader scope. See examples/07_auth/ for session-cookie + bearer-token patterns.

For rate limiting, pair with slowapi or asgi-ratelimit as standard Starlette middleware.

Examples

Path Shows
examples/01_cli_quickstart/ Zero-config CLI demo
examples/02_fastapi_basic/ Mount in FastAPI
examples/03_flask_basic/ Mount in Flask via a2wsgi
examples/04_custom_branding/ Custom logo + CSS
examples/05_custom_storage/ SQLite FileStorage
examples/06_custom_cache/ TTL FileCache decorator
examples/07_auth/ Session cookie + bearer token auth

Linux

groupdocs-viewer-net needs libgdiplus, libfontconfig1, fonts-liberation, and fonts-dejavu for rendering. The bundled Dockerfile installs them; for bare metal:

sudo apt-get install -y libgdiplus libfontconfig1 fontconfig fonts-liberation fonts-dejavu

Documentation

Development

pip install -e ".[dev]"
pytest                         # 107 passing (~21s; 5 e2e tests render a real DOCX)
ruff check src tests
mypy src

License

MIT — see LICENSE.

Support

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

groupdocs_viewer_net_ui-26.5.0.tar.gz (2.4 MB view details)

Uploaded Source

Built Distribution

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

groupdocs_viewer_net_ui-26.5.0-py3-none-any.whl (1.7 MB view details)

Uploaded Python 3

File details

Details for the file groupdocs_viewer_net_ui-26.5.0.tar.gz.

File metadata

  • Download URL: groupdocs_viewer_net_ui-26.5.0.tar.gz
  • Upload date:
  • Size: 2.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for groupdocs_viewer_net_ui-26.5.0.tar.gz
Algorithm Hash digest
SHA256 2d98479148f1787a04ec2590e4e328870bcc98ca62cdc59f9bcb41ead1a89d04
MD5 0a4eaaa506db8d85003b884f9216d6b6
BLAKE2b-256 60912a096b34c3fbb0c5ea7536526dd9d00778bbb9e2fc1f6bee036039987808

See more details on using hashes here.

File details

Details for the file groupdocs_viewer_net_ui-26.5.0-py3-none-any.whl.

File metadata

File hashes

Hashes for groupdocs_viewer_net_ui-26.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8817909650e5269483962eed19cf75e05f227177d1496bd8f4a39faf919d950e
MD5 9b80ace1f2401b078571fcd5fc49c028
BLAKE2b-256 b0626e49ce8c21c3e04a56d5b1eb3a0a4e853e52efe683fa431379c19c35ef71

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