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.4.0.post1.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.

File details

Details for the file groupdocs_viewer_net_ui-26.4.0.post1.tar.gz.

File metadata

File hashes

Hashes for groupdocs_viewer_net_ui-26.4.0.post1.tar.gz
Algorithm Hash digest
SHA256 e314def84728c96b0294560e484ad407174847fefd11886bc5eb3dd19f24a460
MD5 cb75e5b77407229edddebc0d042776fa
BLAKE2b-256 80a4d0b5d531ed4d12d1cdb65929caa5fa6af8697fe66df66ed09b37560da2d4

See more details on using hashes here.

File details

Details for the file groupdocs_viewer_net_ui-26.4.0.post1-py3-none-any.whl.

File metadata

File hashes

Hashes for groupdocs_viewer_net_ui-26.4.0.post1-py3-none-any.whl
Algorithm Hash digest
SHA256 5e7eaa7bc492c2048a4bd386341d6b509f4b90719f4f951abe4a1908ae9d63b1
MD5 851be39b16ba119454dbc10491d747e5
BLAKE2b-256 3fc2f37cf78675476177d965b7da4b975b538e7a55880f82fabb4596cc05acda

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