Skip to main content

JupyterLab Document Reader Extension

GitHub Actions npm version PyPI version Total PyPI downloads JupyterLab 4 Brought To You By KOLOMOLO

A JupyterLab extension that displays Microsoft Word (DOCX) documents, PowerPoint (PPTX) presentations, Excel (XLSX) workbooks, OpenDocument text (ODT) and presentation (ODP) files, and Rich Text Format (RTF) files in JupyterLab. The browser renders each file from its bytes with an established open-source viewer library: no conversion to PDF, no LibreOffice and no server-side processing.

PPTX presentation with slide thumbnails, navigation, zoom and find

DOCX document rendered as pages

Features

The extension offers exactly what each viewer library offers, and adds no feature of its own.

Format Viewer library Licence What you get
DOCX docx-preview Apache-2.0 Pages with headers, footers, footnotes, tables, images and numbering
PPTX @aiden0z/pptx-renderer Apache-2.0 One slide at a time, slide thumbnails, previous and next, zoom and fit, find with highlight
RTF rtf.js MIT Formatted text and embedded WMF or EMF pictures
ODT, ODP @opendocument/odr-core MPL-2.0 Pages or slides one below another, zoom and fit, find with highlight
XLSX @silurus/ooxml MIT Sheets with the viewer's own sheet tabs, zoom and 100%, find across sheets
  • Keys in a presentation: left and right arrows, PageUp, PageDown, Home, End
  • Find in a PPTX, ODT, ODP or XLSX file: Enter for the next match, Shift+Enter for the previous one
  • Links in a DOCX, RTF, ODT or ODP document: http, https and mailto links open in a new tab, # links scroll inside the document, any other link is disabled; in an XLSX workbook the viewer opens http, https, mailto and tel links, and links without a scheme such as other.xlsx (resolved against the JupyterLab address), in a new tab, and ignores links with any other scheme
  • ODT and ODP pages run in a frame sandboxed with allow-scripts only, so neither the viewer's script nor the document can reach or navigate JupyterLab
  • Read-only: files are never modified
  • Each viewer library loads only when a file of its format is opened

Caveats

  • Legacy binary .doc and .ppt files have no browser renderer and show a message asking to save the file as DOCX or PPTX
  • DOCX pages break only at the page and section breaks written in the file, not where Word would flow text onto a new page, so a long section shows as one tall page
  • HTML that a DOCX embeds as an altChunk part is not shown, because docx-preview would run any script in it inside the JupyterLab page; a DOCX whose only content is such a part shows an empty page
  • Word documents and RTF files have no zoom, page counter or table of contents, because their viewers offer none; the browser's own find (Ctrl+F) searches their text
  • ODT pages break only at the page breaks written in the file, as DOCX pages do
  • An ODP presentation shows its slides one below another, with no thumbnails and no previous or next buttons, because its viewer offers neither
  • An XLSX workbook shows the formula results saved in the file and never recalculates; a file saved without results, for example one written by openpyxl, shows empty formula cells
  • Legacy .xls workbooks and OpenDocument spreadsheets (.ods) are not opened by this extension
  • The ODF and XLSX viewers add about 8 MB of JavaScript and WebAssembly to the package; each loads only when a file of its format is opened
  • @opendocument/odr-core is licensed under MPL-2.0 and bundled unmodified; its source code is at OpenDocument.core

Requirements

  • JupyterLab >= 4.6.0
  • Python >= 3.10

Install

pip install jupyterlab_doc_reader_extension

Usage

Open any .docx, .pptx or .rtf file from the JupyterLab file browser. The document opens in a read-only viewer tab.

Uninstall

To remove the extension, execute:

pip uninstall jupyterlab_doc_reader_extension

Troubleshoot

If documents open in the text editor instead of the viewer, check that the extension is installed and enabled:

jupyter labextension list

Contributing

Development install

Note: You will need NodeJS to build the extension package.

The jlpm command is JupyterLab's pinned version of yarn that is installed with JupyterLab. You may use yarn or npm in lieu of jlpm below.

# Clone the repo to your local environment
# Change directory to the jupyterlab_doc_reader_extension directory
# Install package in development mode
pip install -e .
# Link your development version of the extension with JupyterLab
jupyter labextension develop . --overwrite
# Rebuild extension Typescript source after making changes
jlpm build

You can watch the source directory and run JupyterLab at the same time in different terminals to watch for changes in the extension's source and automatically rebuild the extension.

# Watch the source directory in one terminal, automatically rebuilding when needed
jlpm watch
# Run JupyterLab in another terminal
jupyter lab

With the watch command running, every saved change will immediately be built locally and available in your running JupyterLab. Refresh JupyterLab to load the change in your browser (you may need to wait several seconds for the extension to be rebuilt).

By default, the jlpm build command generates the source maps for this extension to make it easier to debug using the browser dev tools. To also generate source maps for the JupyterLab core extensions, you can run the following command:

jupyter lab build --minimize=False

Development uninstall

pip uninstall jupyterlab_doc_reader_extension

In development mode, you will also need to remove the symlink created by jupyter labextension develop command. To find its location, you can run jupyter labextension list to figure out where the labextensions folder is located. Then you can remove the symlink named jupyterlab_doc_reader_extension within that folder.

Testing the extension

Frontend tests

This extension is using Jest for JavaScript code testing.

To execute them, execute:

jlpm
jlpm test

Integration tests

This extension uses Playwright for the integration tests (aka user level tests). More precisely, the JupyterLab helper Galata is used to handle testing the extension in JupyterLab.

More information are provided within the ui-tests README. The documents the tests open live in ui-tests/tests/fixtures/; make_fixtures.py there regenerates them.

Packaging the extension

See RELEASE

Metadata

Release files for jupyterlab-doc-reader-extension 1.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for jupyterlab-doc-reader-extension 1.2.1
File Size Uploaded
jupyterlab_doc_reader_extension-1.2.1.tar.gz 4.7 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for jupyterlab-doc-reader-extension 1.2.1
File Interpreter ABI Platform
jupyterlab_doc_reader_extension-1.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 13.3 MB

Release files / jupyterlab_doc_reader_extension-1.2.1.tar.gz

Download URL jupyterlab_doc_reader_extension-1.2.1.tar.gz
Size 4.7 MB
Tags Source
SHA-256 checksum
How to use checksums
59aabebf9dcc75dcaebd0b82a2ba4a7284c7d3a53958d8f8746059e523c924af
BLAKE2b-256 checksum
How to use checksums
46be79219f8aee6491924a855782a876602b536ddc3b17e1404dda39edeab376
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release files / jupyterlab_doc_reader_extension-1.2.1-py3-none-any.whl

Download URL jupyterlab_doc_reader_extension-1.2.1-py3-none-any.whl
Size 8.7 MB
Tags Python 3
SHA-256 checksum
How to use checksums
60b83dafe70eb1675414fef19ff56c1401265894119fdaa576def0d00fe97775
BLAKE2b-256 checksum
How to use checksums
5191d2a1fbc1950e5b0a444950395eb2743264645fca9ad489e752b9f3ee7958
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release history Release notifications | RSS feed

This release

1.2.1 This release

2 release files

1.1.12

2 release files

1.1.10

2 release files

1.1.9

2 release files

1.1.8

2 release files

1.1.7

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

0.5.41

2 release files

0.5.40

2 release files

0.5.37

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page