Skip to main content

Streamlit component for PDF visualisation and manipulation

Project description

streamlit-pdf-viewer

Component allowing the visualisation and manipulation of PDF documents in streamlit

Work in progress

We are early in the development, looking for contributors. Currently, it has been tested on Chrome and Firefox.

screenshot.png

You can see an application in action here.

Getting started

pip install streamlit-pdf-viewer

In your streamlit application, you can use it as:

import streamlit as st
from streamlit_pdf_viewer import pdf_viewer

pdf_viewer("str, path or bytes")

Options

Params

In the following table the list of parameters that can be provided to the pdf_viewer function:

name description
input The source of the PDF file. Accepts a file path, URL, or binary data.
width Width of the PDF viewer in pixels. It defaults to 700 pixels.
height Height of the PDF viewer in pixels. If not provided, the viewer shows the whole content.
annotations A list of annotations to be overlaid on the PDF. Each annotation should be a dictionary.
pages_vertical_spacing The vertical space (in pixels) between each page of the PDF. Defaults to 2 pixels.
annotation_outline_size Size of the outline around each annotation in pixels. Defaults to 1 pixel.
rendering Type of rendering. The default value "unwrap", which unwraps the PDF with pdf.js, and supports the visualisation of annotations. Other values are "legacy_iframe" and "legacy_embed" which use the legacy approach of injecting the document into an <embed> or <iframe>. These methods enable the default pdf viewer of Firefox/Chrome/Edge that contains additional features we are still working to implement for the "unwrap" method. NOTE: Annotations are ignored for both 'legacy_iframe' and 'legacy_embed'.

Developers notes

Environment

  • Python >= 3.8
  • Node.js >= 16
  • Streamlit 1.28.2

Configure environment for development

First, make sure that _RELEASE = False in streamlit_pdf_viewer/__init__.py. To run the component in development mode, use the following commands:

streamlit run my_component/__init__.py

cd frontend
npm run serve

These commands will start the Streamlit application and serve the Node.js component. Please make sure you're in the correct directory before running these commands.

Integrate into a streamlit application

  1. Build the frontend part:

    cd frontend
    export NODE_OPTIONS=--openssl-legacy-provider
    npm run build 
    
  2. Make sure that _RELEASE = True in streamlit_pdf_viewer/__init__.py.

  3. move to the streamlit_application and run

    pip install -e {path of component}
    

Release

bump-my-version bump patch | minor | major
git push
git push --tags 

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

streamlit-pdf-viewer-0.0.5.tar.gz (2.2 MB view details)

Uploaded Source

Built Distribution

streamlit_pdf_viewer-0.0.5-py3-none-any.whl (2.2 MB view details)

Uploaded Python 3

File details

Details for the file streamlit-pdf-viewer-0.0.5.tar.gz.

File metadata

  • Download URL: streamlit-pdf-viewer-0.0.5.tar.gz
  • Upload date:
  • Size: 2.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for streamlit-pdf-viewer-0.0.5.tar.gz
Algorithm Hash digest
SHA256 a7f419427ba3dd923d5d88adb3ce27389a3de93023c577e4fc1e201f783f1978
MD5 60647113ff6702c5f525166ff6398e4f
BLAKE2b-256 09fa4a7e89bdc5d6e2a6d1b228cfaf436dad0db6dc351f98856ff14f5cb3fbcc

See more details on using hashes here.

File details

Details for the file streamlit_pdf_viewer-0.0.5-py3-none-any.whl.

File metadata

File hashes

Hashes for streamlit_pdf_viewer-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 11bd43ccad7c39aa3cadf7ed3fee3d351bc920cecbc8ec3caf787854183d2fa3
MD5 66e8401c24ae9f46c2effdd1c179dbce
BLAKE2b-256 ec32bbc57b0a1fea593f5f919911a784be6edf096eaf9e6e86de64a0cdae966f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page