Skip to content

Commit

Permalink
Merge branch 'main' into fix-problem-with-chrome
Browse files Browse the repository at this point in the history
  • Loading branch information
lfoppiano committed Sep 10, 2024
2 parents 3e0de40 + a96da5b commit d05af86
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .bumpversion.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tool.bumpversion]
current_version = "0.0.18-dev0"
current_version = "0.0.18-rc0"
commit = "true"
tag = "true"
tag_name = "v{new_version}"
Expand Down
30 changes: 25 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,28 @@

# streamlit-pdf-viewer

Streamlit component that allows the visualisation and enrichment of PDF documents
Tested on Chrome and Firefox. You can see an [application](https://github.com/lfoppiano/structure-vision) in action [here](https://structure-vision.streamlit.app/).
Streamlit component that allows the visualisation and enrichment of PDF documents.
You can see an [application](https://github.com/lfoppiano/structure-vision) in action [here](https://structure-vision.streamlit.app/).

<img src="https://github.com/lfoppiano/streamlit-pdf-viewer/raw/main/docs/screenshot.png" width=500 align="right" />

### Work in progress
We are early in the development, and we appreciate new contributors.
## Features
- Show PDF files in a Streamlit application with a simple command
- Based on the pdf.js library
- Support showing the PDF with the native pdf.js browser's viewer: "legacy" (with limitations, no annotations, no scrolling, etc..)
- Visualize annotations on top of the PDF documents
- Render text on top of the PDF document, allowing copy-paste
- Allow to render specific pages of the PDF document
- Scroll to a specific page
- Scroll to a specific annotation

## Limitations
- Tested and developed to support Firefox and Chrome.
- The legacy visualization works only on Firefox and does not support annotations
- Our Javascript skills are limited, so all troubleshooting may take time
- The component is still in development, so expect some bugs and limitations
- The streamlit reload at each action may render slowly for complex PDF documents


## Getting started

Expand All @@ -28,7 +43,12 @@ from streamlit_pdf_viewer import pdf_viewer
pdf_viewer("str, path or bytes")
```

## Options
### Caveats

Here some caveats to be aware of:
- Is mandatory to specify a `width` to show PDF document on tabs and expanders, otherwise, the viewer will not be displayed on tabs not immediately visible.
- The `legacy` rendering is not supported on Chrome, due to security reasons.


### Params

Expand Down
3 changes: 2 additions & 1 deletion streamlit_pdf_viewer/frontend/src/PdfViewer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export default {
outline: `${props.args.annotation_outline_size * scale}px solid`,
outlineColor: annoObj.color,
cursor: 'pointer',
'z-index': 10
'z-index': 1
};
if (index) {
loadedAnnotations.value.push(`annotation-${index}`);
Expand Down Expand Up @@ -148,6 +148,7 @@ export default {
const textContent = await page.getTextContent();
const textLayerDiv = document.createElement("div");
textLayerDiv.className = "textLayer"
textLayerDiv.style = "z-index: 2"
// textLayerDiv.style.position = "absolute";
// textLayerDiv.style.height = `${viewport.height}px`;
// textLayerDiv.style.width = `${viewport.width}px`;
Expand Down

0 comments on commit d05af86

Please sign in to comment.