streamlit-pdf-viewer 0.0.23.dev1__tar.gz → 0.0.24.dev0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {streamlit_pdf_viewer-0.0.23.dev1 → streamlit_pdf_viewer-0.0.24.dev0}/.bumpversion.toml +1 -1
- {streamlit_pdf_viewer-0.0.23.dev1/streamlit_pdf_viewer.egg-info → streamlit_pdf_viewer-0.0.24.dev0}/PKG-INFO +18 -17
- {streamlit_pdf_viewer-0.0.23.dev1 → streamlit_pdf_viewer-0.0.24.dev0}/README.md +17 -16
- {streamlit_pdf_viewer-0.0.23.dev1 → streamlit_pdf_viewer-0.0.24.dev0}/streamlit_pdf_viewer/__init__.py +42 -38
- {streamlit_pdf_viewer-0.0.23.dev1 → streamlit_pdf_viewer-0.0.24.dev0}/streamlit_pdf_viewer/frontend/dist/index.html +1 -1
- streamlit_pdf_viewer-0.0.24.dev0/streamlit_pdf_viewer/frontend/dist/js/app.88fce03e.js +2 -0
- streamlit_pdf_viewer-0.0.24.dev0/streamlit_pdf_viewer/frontend/dist/js/app.88fce03e.js.map +1 -0
- streamlit_pdf_viewer-0.0.24.dev0/streamlit_pdf_viewer/frontend/dist/js/chunk-vendors.d2e687f7.js +53 -0
- streamlit_pdf_viewer-0.0.23.dev1/streamlit_pdf_viewer/frontend/dist/js/chunk-vendors.a7b421ed.js.map → streamlit_pdf_viewer-0.0.24.dev0/streamlit_pdf_viewer/frontend/dist/js/chunk-vendors.d2e687f7.js.map +1 -1
- {streamlit_pdf_viewer-0.0.23.dev1 → streamlit_pdf_viewer-0.0.24.dev0/streamlit_pdf_viewer.egg-info}/PKG-INFO +18 -17
- {streamlit_pdf_viewer-0.0.23.dev1 → streamlit_pdf_viewer-0.0.24.dev0}/streamlit_pdf_viewer.egg-info/SOURCES.txt +4 -4
- streamlit_pdf_viewer-0.0.23.dev1/streamlit_pdf_viewer/frontend/dist/js/app.91327107.js +0 -2
- streamlit_pdf_viewer-0.0.23.dev1/streamlit_pdf_viewer/frontend/dist/js/app.91327107.js.map +0 -1
- streamlit_pdf_viewer-0.0.23.dev1/streamlit_pdf_viewer/frontend/dist/js/chunk-vendors.a7b421ed.js +0 -53
- {streamlit_pdf_viewer-0.0.23.dev1 → streamlit_pdf_viewer-0.0.24.dev0}/MANIFEST.in +0 -0
- {streamlit_pdf_viewer-0.0.23.dev1 → streamlit_pdf_viewer-0.0.24.dev0}/setup.cfg +0 -0
- {streamlit_pdf_viewer-0.0.23.dev1 → streamlit_pdf_viewer-0.0.24.dev0}/setup.py +0 -0
- {streamlit_pdf_viewer-0.0.23.dev1 → streamlit_pdf_viewer-0.0.24.dev0}/streamlit_pdf_viewer/frontend/dist/css/app.1df382f3.css +0 -0
- {streamlit_pdf_viewer-0.0.23.dev1 → streamlit_pdf_viewer-0.0.24.dev0}/streamlit_pdf_viewer/frontend/dist/css/chunk-vendors.ee6905b7.css +0 -0
- {streamlit_pdf_viewer-0.0.23.dev1 → streamlit_pdf_viewer-0.0.24.dev0}/streamlit_pdf_viewer/frontend/dist/img/altText_add.7748ee93.svg +0 -0
- {streamlit_pdf_viewer-0.0.23.dev1 → streamlit_pdf_viewer-0.0.24.dev0}/streamlit_pdf_viewer/frontend/dist/img/altText_done.1026be11.svg +0 -0
- {streamlit_pdf_viewer-0.0.23.dev1 → streamlit_pdf_viewer-0.0.24.dev0}/streamlit_pdf_viewer/frontend/dist/img/cursor-editorFreeHighlight.1fed7bb7.svg +0 -0
- {streamlit_pdf_viewer-0.0.23.dev1 → streamlit_pdf_viewer-0.0.24.dev0}/streamlit_pdf_viewer/frontend/dist/img/cursor-editorFreeText.0b596377.svg +0 -0
- {streamlit_pdf_viewer-0.0.23.dev1 → streamlit_pdf_viewer-0.0.24.dev0}/streamlit_pdf_viewer/frontend/dist/img/cursor-editorInk.f94c2f42.svg +0 -0
- {streamlit_pdf_viewer-0.0.23.dev1 → streamlit_pdf_viewer-0.0.24.dev0}/streamlit_pdf_viewer/frontend/dist/img/cursor-editorTextHighlight.5636640c.svg +0 -0
- {streamlit_pdf_viewer-0.0.23.dev1 → streamlit_pdf_viewer-0.0.24.dev0}/streamlit_pdf_viewer/frontend/dist/img/editor-toolbar-delete.6694a89f.svg +0 -0
- {streamlit_pdf_viewer-0.0.23.dev1 → streamlit_pdf_viewer-0.0.24.dev0}/streamlit_pdf_viewer/frontend/dist/img/toolbarButton-editorHighlight.c3287eaa.svg +0 -0
- {streamlit_pdf_viewer-0.0.23.dev1 → streamlit_pdf_viewer-0.0.24.dev0}/streamlit_pdf_viewer/frontend/dist/img/toolbarButton-menuArrow.37a6145d.svg +0 -0
- {streamlit_pdf_viewer-0.0.23.dev1 → streamlit_pdf_viewer-0.0.24.dev0}/streamlit_pdf_viewer.egg-info/dependency_links.txt +0 -0
- {streamlit_pdf_viewer-0.0.23.dev1 → streamlit_pdf_viewer-0.0.24.dev0}/streamlit_pdf_viewer.egg-info/requires.txt +0 -0
- {streamlit_pdf_viewer-0.0.23.dev1 → streamlit_pdf_viewer-0.0.24.dev0}/streamlit_pdf_viewer.egg-info/top_level.txt +0 -0
- {streamlit_pdf_viewer-0.0.23.dev1 → streamlit_pdf_viewer-0.0.24.dev0}/tests/__init__.py +0 -0
- {streamlit_pdf_viewer-0.0.23.dev1 → streamlit_pdf_viewer-0.0.24.dev0}/tests/e2e_utils.py +0 -0
- {streamlit_pdf_viewer-0.0.23.dev1 → streamlit_pdf_viewer-0.0.24.dev0}/tests/test_embed_height.py +0 -0
- {streamlit_pdf_viewer-0.0.23.dev1 → streamlit_pdf_viewer-0.0.24.dev0}/tests/test_embed_no_args.py +0 -0
- {streamlit_pdf_viewer-0.0.23.dev1 → streamlit_pdf_viewer-0.0.24.dev0}/tests/test_embed_width.py +0 -0
- {streamlit_pdf_viewer-0.0.23.dev1 → streamlit_pdf_viewer-0.0.24.dev0}/tests/test_embed_width_height.py +0 -0
- {streamlit_pdf_viewer-0.0.23.dev1 → streamlit_pdf_viewer-0.0.24.dev0}/tests/test_iframe_height.py +0 -0
- {streamlit_pdf_viewer-0.0.23.dev1 → streamlit_pdf_viewer-0.0.24.dev0}/tests/test_iframe_no_args.py +0 -0
- {streamlit_pdf_viewer-0.0.23.dev1 → streamlit_pdf_viewer-0.0.24.dev0}/tests/test_iframe_width.py +0 -0
- {streamlit_pdf_viewer-0.0.23.dev1 → streamlit_pdf_viewer-0.0.24.dev0}/tests/test_iframe_width_height.py +0 -0
- {streamlit_pdf_viewer-0.0.23.dev1 → streamlit_pdf_viewer-0.0.24.dev0}/tests/test_invalid_params.py +0 -0
- {streamlit_pdf_viewer-0.0.23.dev1 → streamlit_pdf_viewer-0.0.24.dev0}/tests/test_rendering_text.py +0 -0
- {streamlit_pdf_viewer-0.0.23.dev1 → streamlit_pdf_viewer-0.0.24.dev0}/tests/test_resolution_boost.py +0 -0
- {streamlit_pdf_viewer-0.0.23.dev1 → streamlit_pdf_viewer-0.0.24.dev0}/tests/test_tabs.py +0 -0
- {streamlit_pdf_viewer-0.0.23.dev1 → streamlit_pdf_viewer-0.0.24.dev0}/tests/test_tabs_2.py +0 -0
- {streamlit_pdf_viewer-0.0.23.dev1 → streamlit_pdf_viewer-0.0.24.dev0}/tests/test_unwrap_height.py +0 -0
- {streamlit_pdf_viewer-0.0.23.dev1 → streamlit_pdf_viewer-0.0.24.dev0}/tests/test_unwrap_no_args.py +0 -0
- {streamlit_pdf_viewer-0.0.23.dev1 → streamlit_pdf_viewer-0.0.24.dev0}/tests/test_unwrap_width.py +0 -0
- {streamlit_pdf_viewer-0.0.23.dev1 → streamlit_pdf_viewer-0.0.24.dev0}/tests/test_unwrap_width_height.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: streamlit-pdf-viewer
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.24.dev0
|
|
4
4
|
Summary: Streamlit component for PDF visualisation and manipulation
|
|
5
5
|
Home-page: https://github.com/lfoppiano/streamlit-pdf-viewer
|
|
6
6
|
Author: Luca Foppiano, Tomoya Mato
|
|
@@ -40,18 +40,18 @@ action [here](https://structure-vision.streamlit.app/).
|
|
|
40
40
|
- Based on the pdf.js library
|
|
41
41
|
- Visualize annotations on top of the PDF documents
|
|
42
42
|
- Render text on top of the PDF document, allowing copy-paste
|
|
43
|
-
- Allow
|
|
43
|
+
- Allow rendering specific pages of the PDF document
|
|
44
44
|
- Scroll to a specific page
|
|
45
45
|
- Scroll to a specific annotation
|
|
46
46
|
- Allow custom callbacks when an annotation is clicked
|
|
47
47
|
- Additional support showing PDF documents using the native pdf.js browser's viewer: "legacy" (with limitations, no
|
|
48
|
-
annotations, no scrolling, etc
|
|
48
|
+
annotations, no scrolling, etc.)
|
|
49
49
|
|
|
50
50
|
## Limitations
|
|
51
51
|
|
|
52
52
|
- Tested and developed to support Firefox and Chrome.
|
|
53
53
|
- The legacy visualization works only on Firefox and does not support annotations
|
|
54
|
-
- Our
|
|
54
|
+
- Our JavaScript skills are limited, so all troubleshooting may take time
|
|
55
55
|
- The component is still in development, so expect some bugs and limitations
|
|
56
56
|
- The streamlit reload at each action may render slowly for complex PDF documents
|
|
57
57
|
|
|
@@ -106,13 +106,16 @@ In the following table the list of parameters that can be provided to the `pdf_v
|
|
|
106
106
|
|
|
107
107
|
### Annotation format
|
|
108
108
|
|
|
109
|
-
The
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
The
|
|
113
|
-
|
|
109
|
+
The annotation format has been derived from the [Grobid's coordinate formats](https://grobid.readthedocs.io/en/latest/Coordinates-in-PDF/), which are described as a list of "bounding boxes".
|
|
110
|
+
The annotations are expressed as a dictionary of six elements; the page, x and y indicate the top left point.
|
|
111
|
+
The `color` can be expressed following the HTML CSS convention.
|
|
112
|
+
The `border` style also follow the HTML conventions limited to these values: `solid`, `dashed`, `dotted`, `double`, `groove`, `ridge`, `inset`, `outset`.
|
|
113
|
+
Any other value will result in the default value: `solid`.
|
|
114
114
|
|
|
115
|
-
|
|
115
|
+
Annotation unique identifiers are expressed by the `id` field, if `id` is not specified, an identifier will be generated during rendering.
|
|
116
|
+
Furthermore, the HTML identifier will be generated as `#annotation-{annotation.id}`.
|
|
117
|
+
|
|
118
|
+
Here is an example:
|
|
116
119
|
|
|
117
120
|
```json
|
|
118
121
|
[
|
|
@@ -125,13 +128,10 @@ Here an example:
|
|
|
125
128
|
"color": "red",
|
|
126
129
|
"border": "solid"
|
|
127
130
|
},
|
|
128
|
-
|
|
129
|
-
...
|
|
130
|
-
]
|
|
131
|
+
[...]
|
|
131
132
|
```
|
|
132
133
|
|
|
133
|
-
|
|
134
|
-
`inset`, `outset`. Any other value will result in the default value: `solid`.
|
|
134
|
+
|
|
135
135
|
|
|
136
136
|
The example shown in our screenshot can be found [here](resources/annotations.json).
|
|
137
137
|
|
|
@@ -227,6 +227,7 @@ git push --tags
|
|
|
227
227
|
|
|
228
228
|
## Acknowledgement
|
|
229
229
|
|
|
230
|
-
The project was initiated at the [National Institute for Materials Science](https://www.nims.go.jp) (NIMS) in Japan.
|
|
230
|
+
The project was initiated by [Luca Foppiano](https://github.com/lfoppiano) at the [National Institute for Materials Science](https://www.nims.go.jp) (NIMS) in Japan.
|
|
231
231
|
Currently, the development is possible thanks to [ScienciLAB](https://www.sciencialab.com).
|
|
232
|
-
|
|
232
|
+
|
|
233
|
+
Main contacts: Luca Foppiano and [Tomoya Mato](https://github.com/t29mato).
|
|
@@ -18,18 +18,18 @@ action [here](https://structure-vision.streamlit.app/).
|
|
|
18
18
|
- Based on the pdf.js library
|
|
19
19
|
- Visualize annotations on top of the PDF documents
|
|
20
20
|
- Render text on top of the PDF document, allowing copy-paste
|
|
21
|
-
- Allow
|
|
21
|
+
- Allow rendering specific pages of the PDF document
|
|
22
22
|
- Scroll to a specific page
|
|
23
23
|
- Scroll to a specific annotation
|
|
24
24
|
- Allow custom callbacks when an annotation is clicked
|
|
25
25
|
- Additional support showing PDF documents using the native pdf.js browser's viewer: "legacy" (with limitations, no
|
|
26
|
-
annotations, no scrolling, etc
|
|
26
|
+
annotations, no scrolling, etc.)
|
|
27
27
|
|
|
28
28
|
## Limitations
|
|
29
29
|
|
|
30
30
|
- Tested and developed to support Firefox and Chrome.
|
|
31
31
|
- The legacy visualization works only on Firefox and does not support annotations
|
|
32
|
-
- Our
|
|
32
|
+
- Our JavaScript skills are limited, so all troubleshooting may take time
|
|
33
33
|
- The component is still in development, so expect some bugs and limitations
|
|
34
34
|
- The streamlit reload at each action may render slowly for complex PDF documents
|
|
35
35
|
|
|
@@ -84,13 +84,16 @@ In the following table the list of parameters that can be provided to the `pdf_v
|
|
|
84
84
|
|
|
85
85
|
### Annotation format
|
|
86
86
|
|
|
87
|
-
The
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
The
|
|
91
|
-
|
|
87
|
+
The annotation format has been derived from the [Grobid's coordinate formats](https://grobid.readthedocs.io/en/latest/Coordinates-in-PDF/), which are described as a list of "bounding boxes".
|
|
88
|
+
The annotations are expressed as a dictionary of six elements; the page, x and y indicate the top left point.
|
|
89
|
+
The `color` can be expressed following the HTML CSS convention.
|
|
90
|
+
The `border` style also follow the HTML conventions limited to these values: `solid`, `dashed`, `dotted`, `double`, `groove`, `ridge`, `inset`, `outset`.
|
|
91
|
+
Any other value will result in the default value: `solid`.
|
|
92
92
|
|
|
93
|
-
|
|
93
|
+
Annotation unique identifiers are expressed by the `id` field, if `id` is not specified, an identifier will be generated during rendering.
|
|
94
|
+
Furthermore, the HTML identifier will be generated as `#annotation-{annotation.id}`.
|
|
95
|
+
|
|
96
|
+
Here is an example:
|
|
94
97
|
|
|
95
98
|
```json
|
|
96
99
|
[
|
|
@@ -103,13 +106,10 @@ Here an example:
|
|
|
103
106
|
"color": "red",
|
|
104
107
|
"border": "solid"
|
|
105
108
|
},
|
|
106
|
-
|
|
107
|
-
...
|
|
108
|
-
]
|
|
109
|
+
[...]
|
|
109
110
|
```
|
|
110
111
|
|
|
111
|
-
|
|
112
|
-
`inset`, `outset`. Any other value will result in the default value: `solid`.
|
|
112
|
+
|
|
113
113
|
|
|
114
114
|
The example shown in our screenshot can be found [here](resources/annotations.json).
|
|
115
115
|
|
|
@@ -205,6 +205,7 @@ git push --tags
|
|
|
205
205
|
|
|
206
206
|
## Acknowledgement
|
|
207
207
|
|
|
208
|
-
The project was initiated at the [National Institute for Materials Science](https://www.nims.go.jp) (NIMS) in Japan.
|
|
208
|
+
The project was initiated by [Luca Foppiano](https://github.com/lfoppiano) at the [National Institute for Materials Science](https://www.nims.go.jp) (NIMS) in Japan.
|
|
209
209
|
Currently, the development is possible thanks to [ScienciLAB](https://www.sciencialab.com).
|
|
210
|
-
|
|
210
|
+
|
|
211
|
+
Main contacts: Luca Foppiano and [Tomoya Mato](https://github.com/t29mato).
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import base64
|
|
2
2
|
import os
|
|
3
3
|
from pathlib import Path
|
|
4
|
-
from typing import Union, List, Optional, Callable
|
|
4
|
+
from typing import Union, List, Optional, Callable, Dict
|
|
5
5
|
|
|
6
6
|
import streamlit.components.v1 as components
|
|
7
7
|
import json
|
|
@@ -27,10 +27,10 @@ else:
|
|
|
27
27
|
|
|
28
28
|
def pdf_viewer(
|
|
29
29
|
input: Union[str, Path, bytes],
|
|
30
|
-
width: Union[str,int] = None,
|
|
30
|
+
width: Union[str, int] = None,
|
|
31
31
|
height: int = None,
|
|
32
32
|
key=None,
|
|
33
|
-
annotations:
|
|
33
|
+
annotations: List[Dict[str, Union[str, int, float, bool]]] = (),
|
|
34
34
|
pages_vertical_spacing: int = 2,
|
|
35
35
|
annotation_outline_size: int = 1,
|
|
36
36
|
rendering: str = RENDERING_UNWRAP,
|
|
@@ -40,7 +40,7 @@ def pdf_viewer(
|
|
|
40
40
|
scroll_to_page: int = None,
|
|
41
41
|
scroll_to_annotation: int = None,
|
|
42
42
|
on_annotation_click: Optional[Callable[[dict], None]] = None,
|
|
43
|
-
|
|
43
|
+
):
|
|
44
44
|
"""
|
|
45
45
|
pdf_viewer function to display a PDF file in a Streamlit app.
|
|
46
46
|
|
|
@@ -108,6 +108,11 @@ def pdf_viewer(
|
|
|
108
108
|
if height is None:
|
|
109
109
|
height = "100%"
|
|
110
110
|
|
|
111
|
+
if not isinstance(annotations, list):
|
|
112
|
+
raise TypeError("annotations must be a list of dictionaries")
|
|
113
|
+
if any(not isinstance(annotation, dict) for annotation in annotations):
|
|
114
|
+
raise TypeError("annotations must be a list of dictionaries")
|
|
115
|
+
|
|
111
116
|
base64_pdf = base64.b64encode(binary).decode('utf-8')
|
|
112
117
|
component_value = _component_func(
|
|
113
118
|
binary=base64_pdf,
|
|
@@ -149,28 +154,28 @@ if not _RELEASE:
|
|
|
149
154
|
# pdf_viewer(path, width=800, render_text=True, resolution_boost=values[id])
|
|
150
155
|
#
|
|
151
156
|
# def scroll_to_page(page):
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
157
|
+
# st.markdown(
|
|
158
|
+
# """
|
|
159
|
+
# function(){
|
|
160
|
+
# document.getElementById(""" + page + """).scrollIntoView({behavior: 'smooth'})
|
|
161
|
+
# };
|
|
162
|
+
#
|
|
163
|
+
# function()
|
|
164
|
+
# """, unsafe_allow_html=True)
|
|
165
|
+
|
|
166
|
+
# print(page)
|
|
167
|
+
# st.components.v1.html(
|
|
168
|
+
# """
|
|
169
|
+
# <script>
|
|
170
|
+
# function scrollDown(){
|
|
171
|
+
# page_canvas = document.getElementById('""" + page + """')
|
|
172
|
+
# console.log(page_canvas)
|
|
173
|
+
# page_canvas.scrollIntoView({behavior: 'smooth'})
|
|
174
|
+
# }
|
|
175
|
+
# scrollDown()
|
|
176
|
+
# </script>
|
|
177
|
+
# """
|
|
178
|
+
# )
|
|
174
179
|
|
|
175
180
|
with open("resources/test.pdf", 'rb') as fo:
|
|
176
181
|
binary = fo.read()
|
|
@@ -224,17 +229,16 @@ if not _RELEASE:
|
|
|
224
229
|
scroll_to_annotation=2
|
|
225
230
|
)
|
|
226
231
|
|
|
227
|
-
|
|
228
232
|
## Issue with Chrome
|
|
229
233
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
234
|
+
# from glob import glob
|
|
235
|
+
#
|
|
236
|
+
# # paths = glob("/Users/lfoppiano/kDrive/library/articles/materials informatics/polymers/*.pdf")
|
|
237
|
+
# paths = glob("/Users/lfoppiano/development/projects/alirahelth/data/articles/*.pdf")
|
|
238
|
+
# for id, (tab, path) in enumerate(zip(st.tabs(paths),paths)):
|
|
239
|
+
# with tab:
|
|
240
|
+
# with st.container(height=600):
|
|
241
|
+
# if id == 0:
|
|
242
|
+
# pdf_viewer(path, width=500, render_text=True)
|
|
243
|
+
# else:
|
|
244
|
+
# pdf_viewer(path, width=1000, render_text=True)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
<!doctype html><html lang="en"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><title>streamlit_pdf_viewer</title><script defer="defer" src="js/chunk-vendors.
|
|
1
|
+
<!doctype html><html lang="en"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><title>streamlit_pdf_viewer</title><script defer="defer" src="js/chunk-vendors.d2e687f7.js"></script><script defer="defer" src="js/app.88fce03e.js"></script><link href="css/chunk-vendors.ee6905b7.css" rel="stylesheet"><link href="css/app.1df382f3.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but streamlit_pdf_viewer doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div></body></html>
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
(()=>{"use strict";var e={9973:(e,t,n)=>{var r=n(3751),i=n(641);const a={id:"app"};function o(e,t,n,r,o,s){const l=(0,i.g2)("PdfViewer"),d=(0,i.g2)("WithStreamlitConnection");return(0,i.uX)(),(0,i.CE)("div",a,[(0,i.bF)(d,null,{default:(0,i.k6)((({args:e})=>[(0,i.bF)(l,{args:e},null,8,["args"])])),_:1})])}var s=n(33);const l={key:0},d={key:1},c=["src","width","height"],p={key:2},h=["src","width","height"],g={key:3};function u(e,t,n,r,a,o){return(0,i.uX)(),(0,i.CE)("div",{id:"pdfContainer",style:(0,s.Tr)(r.pdfContainerStyle)},["unwrap"===n.args.rendering?((0,i.uX)(),(0,i.CE)("div",l,[(0,i.Lk)("div",{id:"pdfViewer",style:(0,s.Tr)(r.pdfViewerStyle)},null,4)])):"legacy_embed"===n.args.rendering?((0,i.uX)(),(0,i.CE)("div",d,[(0,i.Lk)("embed",{src:`data:application/pdf;base64,${n.args.binary}`,width:`${n.args.width}`,height:`${n.args.height}`,type:"application/pdf"},null,8,c)])):"legacy_iframe"===n.args.rendering?((0,i.uX)(),(0,i.CE)("div",p,[(0,i.Lk)("embed",{src:`data:application/pdf;base64,${n.args.binary}`,width:`${n.args.width}`,height:`${n.args.height}`,type:"application/pdf"},null,8,h)])):((0,i.uX)(),(0,i.CE)("div",g," Error rendering option. "))],4)}n(4114),n(8111),n(2489),n(7588);var v=n(953),w=(n(951),n(9936)),y=n(7445),f=n(2543);const m="pdfjs-dist/cmaps/",b=!0,_=!0,E=["solid","dashed","dotted","double","groove","ridge","inset","outset","none",void 0,null],x={props:["args"],setup(e){const t=(0,v.KR)(0),n=(0,v.KR)(0),r=(0,v.KR)([]),a=(0,v.KR)([]),o=(0,v.KR)([]),s=(0,v.KR)(e.args.height||0),l=(e.args.pages_to_render.length,!0===e.args.render_text),d=(e,t=window.innerWidth)=>{if("string"===typeof e&&e.endsWith("%")){const t=parseFloat(e);if(!isNaN(t))return{type:"percent",value:t/100}}const n=Number(e);return!isNaN(n)&&n>0?{type:"pixel",value:n}:{type:"pixel",value:t}},c=(0,i.EW)((()=>{const t=d(e.args.width,window.innerWidth),n="percent"===t.type?100*t.value+"%":`${t.value}px`;return{width:n,height:e.args.height?`${e.args.height}px`:"auto",overflow:"auto",position:"relative"}})),p={position:"relative"},h=e=>{e&&(e.innerHTML="")},g=(e,t,n,r,i=1)=>{const a=e.getViewport({scale:t,rotation:n}),o=(window.devicePixelRatio||1)*i,s=document.createElement("canvas");return s.id=`canvas_page_${r}`,s.height=a.height*o,s.width=a.width*o,s.style.width=`${a.width}px`,s.style.height=`${a.height}px`,s.style.display="block",s.getContext("2d").scale(o,o),s},u=(t,n,r,i)=>{const a=document.createElement("div");t.id=`${t.id||n}`,a.id=`annotation-${t.id}`,a.setAttribute("data-index",t.id),a.style.position="absolute",a.style.left=t.x*i+"px",a.style.top=t.y*i+"px",a.style.width=t.width*i+"px",a.style.height=t.height*i+"px";let o=t.border;t.border&&E.includes(t.border)||(o="solid"),a.style.outline=`${e.args.annotation_outline_size*i}px ${o} ${t.color}`,a.style.cursor=l?"text":"pointer",a.style.pointerEvents=l?"none":"auto",a.style.zIndex=10,l||a.addEventListener("click",(()=>{y.wk.setComponentValue({clicked_annotation:{index:t.id,...t}})})),r.appendChild(a)},x=async(t,n,r,i,a)=>{const o={canvasContext:n.getContext("2d"),viewport:r};await t.render(o).promise;const s=document.createElement("div");s.className="page",s.style.position="relative",s.style.width=`${r.width}px`,s.style.height=`${r.height}px`,s.style.marginBottom=`${e.args.pages_vertical_spacing}px`;const d=document.createElement("div");if(d.className="canvasWrapper",d.style.position="absolute",d.style.top="0",d.style.left="0",d.appendChild(n),s.appendChild(d),l){const e=await t.getTextContent(),n=document.createElement("div");n.className="textLayer",n.style.zIndex="11",n.style.position="absolute",n.style.top="0",n.style.left="0",n.style.height=`${r.height}px`,n.style.width=`${r.width}px`;const i=new w.D6({textContentSource:e,container:n,viewport:r,textDivs:[]});await i.render(),s.appendChild(n)}i&&i.length>0&&i.forEach(((e,t)=>{const n=a+t;u(e,n,s,r.scale)}));const c=document.getElementById("pdfViewer");c.appendChild(s)},k=t=>0===e.args.pages_to_render.length?Array.from({length:t},((e,t)=>t+1)):e.args.pages_to_render,C=async(i,s,l)=>{t.value=0,r.value=[],a.value=[],o.value=[];const d=e.args.resolution_boost||1;let c=0;for(let p=1;p<=i.numPages;p++){const h=await i.getPage(p),u=h.rotate,v=h.getViewport({scale:1,rotation:u});if(e.args.height>0){const t=v.width/v.height,r=t*e.args.height;(0===n.value||r<n.value)&&(n.value=r)}const w=n.value/v.width;if(r.value.push(w),a.value.push(v.height),l.includes(p)){const n=g(h,w,u,p,d);s.style.setProperty("--scale-factor",w);const r=h.getViewport({scale:w,rotation:u,intent:"print"}),i=e.args.annotations.filter((e=>Number(e.page)===p));t.value+=n.height/((window.devicePixelRatio||1)*d),await x(h,n,r,i,c),c+=i.length,n.id&&o.value.push(n.id)}}l.length>0&&(t.value-=e.args.pages_vertical_spacing)},$=e=>{console.error(e),window.alert(e.message)},R=async e=>{w.EA.workerSrc="pdfjs-dist/build/pdf.worker.mjs";try{const t=(0,w.YE)({url:e,cMapUrl:m,cMapPacked:b,enableXfa:_}),n=await t.promise,r=document.getElementById("pdfViewer");h(r);const i=k(n.numPages);await C(n,r,i),V()}catch(t){$(t)}},V=()=>{if(e.args.scroll_to_page){const t=document.getElementById(`canvas_page_${e.args.scroll_to_page}`);t&&t.scrollIntoView({behavior:"smooth"})}else if(e.args.scroll_to_annotation){const t=document.querySelector(`[id^="annotation-"][data-index="${e.args.scroll_to_annotation}"]`);t&&t.scrollIntoView({behavior:"smooth",block:"center"})}},N=()=>{const n=e.args.height||t.value;n!==s.value&&(y.wk.setFrameHeight(n),s.value=n)},L=()=>{const t=d(e.args.width,window.innerWidth);let r;r="percent"===t.type?Math.min(Math.floor(t.value*window.innerWidth),window.innerWidth):Math.min(t.value,window.innerWidth),r!==n.value&&(n.value=r)},W=async()=>{try{if(console.log("handleResize"),"unwrap"===e.args.rendering){const t=`data:application/pdf;base64,${e.args.binary}`;L(),await R(t),N()}}catch(t){console.error(t)}},O=(0,f.debounce)(W,200);return(0,i.sV)((()=>{O(),window.addEventListener("resize",O)})),(0,i.hi)((()=>{window.removeEventListener("resize",O)})),{pdfContainerStyle:c,pdfViewerStyle:p}}};var k=n(6262);const C=(0,k.A)(x,[["render",u]]),$=C,R={key:0},V={class:"err__msg"};function N(e,t,n,r,a,o){return(0,i.uX)(),(0,i.CE)("div",null,[""!=e.componentError?((0,i.uX)(),(0,i.CE)("div",R,[t[0]||(t[0]=(0,i.Lk)("h1",{class:"err__title"},"Component Error",-1)),(0,i.Lk)("div",V,"Message: "+(0,s.v_)(e.componentError),1)])):null!=e.renderData?(0,i.RG)(e.$slots,"default",{key:1,args:e.renderData.args,disabled:e.renderData.disabled},void 0,!0):(0,i.Q3)("",!0)])}const L=(0,i.pM)({name:"WithStreamlitConnection",setup(){const e=(0,v.KR)(void 0),t=(0,v.KR)(""),n=n=>{const r=n;e.value=r.detail,t.value=""};return(0,i.sV)((()=>{y.wk.events.addEventListener(y.wk.RENDER_EVENT,n),y.wk.setComponentReady()})),(0,i.$u)((()=>{""!=t.value&&y.wk.setFrameHeight()})),(0,i.hi)((()=>{y.wk.events.removeEventListener(y.wk.RENDER_EVENT,n)})),(0,i.qG)((e=>{t.value=String(e)})),{renderData:e,componentError:t}}}),W=(0,k.A)(L,[["render",N],["__scopeId","data-v-bef81972"]]),O=W,P=(0,i.pM)({name:"App",components:{PdfViewer:$,WithStreamlitConnection:O}}),S=(0,k.A)(P,[["render",o]]),j=S;(0,r.Ef)(j).mount("#app")}},t={};function n(r){var i=t[r];if(void 0!==i)return i.exports;var a=t[r]={id:r,loaded:!1,exports:{}};return e[r].call(a.exports,a,a.exports,n),a.loaded=!0,a.exports}n.m=e,(()=>{var e=[];n.O=(t,r,i,a)=>{if(!r){var o=1/0;for(c=0;c<e.length;c++){for(var[r,i,a]=e[c],s=!0,l=0;l<r.length;l++)(!1&a||o>=a)&&Object.keys(n.O).every((e=>n.O[e](r[l])))?r.splice(l--,1):(s=!1,a<o&&(o=a));if(s){e.splice(c--,1);var d=i();void 0!==d&&(t=d)}}return t}a=a||0;for(var c=e.length;c>0&&e[c-1][2]>a;c--)e[c]=e[c-1];e[c]=[r,i,a]}})(),(()=>{n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})}})(),(()=>{n.g=function(){if("object"===typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"===typeof window)return window}}()})(),(()=>{n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t)})(),(()=>{n.nmd=e=>(e.paths=[],e.children||(e.children=[]),e)})(),(()=>{var e={524:0};n.O.j=t=>0===e[t];var t=(t,r)=>{var i,a,[o,s,l]=r,d=0;if(o.some((t=>0!==e[t]))){for(i in s)n.o(s,i)&&(n.m[i]=s[i]);if(l)var c=l(n)}for(t&&t(r);d<o.length;d++)a=o[d],n.o(e,a)&&e[a]&&e[a][0](),e[a]=0;return n.O(c)},r=self["webpackChunkstreamlit_pdf_viewer"]=self["webpackChunkstreamlit_pdf_viewer"]||[];r.forEach(t.bind(null,0)),r.push=t.bind(null,r.push.bind(r))})();var r=n.O(void 0,[504],(()=>n(9973)));r=n.O(r)})();
|
|
2
|
+
//# sourceMappingURL=app.88fce03e.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"js/app.88fce03e.js","mappings":"gEAEA,MAAMA,EAAa,CCIZC,GAAG,ODFJ,SAAUC,EAAOC,EAAUC,EAAYC,EAAYC,EAAYC,EAAWC,GAC9E,MAAMC,GAAuBC,EAAAA,EAAAA,IAAkB,aACzCC,GAAqCD,EAAAA,EAAAA,IAAkB,2BAE7D,OAAQE,EAAAA,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ByB,EAAI,CAACS,EAAKC,IAAUjB,OAAOkB,UAAUC,eAAe9B,KAAK2B,EAAKC,E,WCAlFnC,EAAoBsC,IAAOlC,IAC1BA,EAAOmC,MAAQ,GACVnC,EAAOoC,WAAUpC,EAAOoC,SAAW,IACjCpC,E,WCER,IAAIqC,EAAkB,CACrB,IAAK,GAaNzC,EAAoBU,EAAEO,EAAKyB,GAA0C,IAA7BD,EAAgBC,GAGxD,IAAIC,EAAuB,CAACC,EAA4BC,KACvD,IAGI5C,EAAUyC,GAHT/B,EAAUmC,EAAaC,GAAWF,EAGhB/H,EAAI,EAC3B,GAAG6F,EAASqC,MAAMzQ,GAAgC,IAAxBkQ,EAAgBlQ,KAAa,CACtD,IAAI0N,KAAY6C,EACZ9C,EAAoByB,EAAEqB,EAAa7C,KACrCD,EAAoBQ,EAAEP,GAAY6C,EAAY7C,IAGhD,GAAG8C,EAAS,IAAIzM,EAASyM,EAAQ/C,EAClC,CAEA,IADG4C,GAA4BA,EAA2BC,GACrD/H,EAAI6F,EAASpL,OAAQuF,IACzB4H,EAAU/B,EAAS7F,GAChBkF,EAAoByB,EAAEgB,EAAiBC,IAAYD,EAAgBC,IACrED,EAAgBC,GAAS,KAE1BD,EAAgBC,GAAW,EAE5B,OAAO1C,EAAoBU,EAAEpK,IAG1B2M,EAAqBC,KAAK,oCAAsCA,KAAK,qCAAuC,GAChHD,EAAmB1I,QAAQoI,EAAqBQ,KAAK,KAAM,IAC3DF,EAAmBxH,KAAOkH,EAAqBQ,KAAK,KAAMF,EAAmBxH,KAAK0H,KAAKF,G,KC7CvF,IAAIG,EAAsBpD,EAAoBU,OAAE/L,EAAW,CAAC,MAAM,IAAOqL,EAAoB,QAC7FoD,EAAsBpD,EAAoBU,EAAE0C,E","sources":["webpack://streamlit_pdf_viewer/./src/App.vue?9ab1","webpack://streamlit_pdf_viewer/./src/App.vue","webpack://streamlit_pdf_viewer/./src/PdfViewer.vue","webpack://streamlit_pdf_viewer/./src/PdfViewer.vue?f557","webpack://streamlit_pdf_viewer/./src/streamlit/WithStreamlitConnection.vue?8d46","webpack://streamlit_pdf_viewer/./src/streamlit/WithStreamlitConnection.vue","webpack://streamlit_pdf_viewer/./src/streamlit/WithStreamlitConnection.vue?1dfc","webpack://streamlit_pdf_viewer/./src/App.vue?7ccd","webpack://streamlit_pdf_viewer/./src/main.ts","webpack://streamlit_pdf_viewer/webpack/bootstrap","webpack://streamlit_pdf_viewer/webpack/runtime/chunk loaded","webpack://streamlit_pdf_viewer/webpack/runtime/define property getters","webpack://streamlit_pdf_viewer/webpack/runtime/global","webpack://streamlit_pdf_viewer/webpack/runtime/hasOwnProperty shorthand","webpack://streamlit_pdf_viewer/webpack/runtime/node module decorator","webpack://streamlit_pdf_viewer/webpack/runtime/jsonp chunk loading","webpack://streamlit_pdf_viewer/webpack/startup"],"sourcesContent":["import { resolveComponent as _resolveComponent, createVNode as _createVNode, withCtx as _withCtx, openBlock as _openBlock, createElementBlock as _createElementBlock } from \"vue\"\n\nconst _hoisted_1 = { id: \"app\" }\n\nexport function render(_ctx: any,_cache: any,$props: any,$setup: any,$data: any,$options: any) {\n const _component_PdfViewer = _resolveComponent(\"PdfViewer\")!\n const _component_WithStreamlitConnection = _resolveComponent(\"WithStreamlitConnection\")!\n\n return (_openBlock(), _createElementBlock(\"div\", _hoisted_1, [\n _createVNode(_component_WithStreamlitConnection, null, {\n default: _withCtx(({ args }) => [\n _createVNode(_component_PdfViewer, { args: args }, null, 8, [\"args\"])\n ]),\n _: 1\n })\n ]))\n}","<!-- \n We bootstrap our Component to Streamlit with our scoped slot in the top-level App.\n This is where scoped slot passes Streamlit `args` data from itself to children MyComponent.\n You should not have to edit this, but are free to do so :)\n-->\n<template>\n <div id=\"app\">\n <WithStreamlitConnection v-slot=\"{ args }\">\n <PdfViewer :args=\"args\" />\n </WithStreamlitConnection>\n </div>\n</template>\n\n<script lang=\"ts\">\nimport { defineComponent } from \"vue\"\nimport PdfViewer from \"./PdfViewer.vue\"\n\n// \"withStreamlitConnection\" is a scoped slot. It bootstraps the\n// connection between your component and the Streamlit app, and handles\n// passing arguments from Python -> Component.\n//\n// You don't need to edit withStreamlitConnection (but you're welcome to!).\nimport WithStreamlitConnection from \"./streamlit/WithStreamlitConnection.vue\"\n\nexport default defineComponent({\n name: \"App\",\n components: {\n PdfViewer,\n WithStreamlitConnection,\n },\n})\n</script>\n\n<style>\nbody {\n margin: 0;\n}\n#app {\n font-family: Avenir, Helvetica, Arial, sans-serif;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n color: #2c3e50;\n}\n</style>\n","<template>\n <div id=\"pdfContainer\" :style=\"pdfContainerStyle\">\n <div v-if=\"args.rendering === 'unwrap'\">\n <div id=\"pdfViewer\" :style=\"pdfViewerStyle\"></div>\n </div>\n <div v-else-if=\"args.rendering === 'legacy_embed'\">\n <embed :src=\"`data:application/pdf;base64,${args.binary}`\" :width=\"`${args.width}`\" :height=\"`${args.height}`\"\n type=\"application/pdf\"/>\n </div>\n <div v-else-if=\"args.rendering === 'legacy_iframe'\">\n <embed :src=\"`data:application/pdf;base64,${args.binary}`\" :width=\"`${args.width}`\" :height=\"`${args.height}`\"\n type=\"application/pdf\"/>\n </div>\n <div v-else>\n Error rendering option.\n </div>\n </div>\n</template>\n\n<script>\nimport { onMounted, onUpdated, computed, ref, onUnmounted } from \"vue\";\nimport \"pdfjs-dist/web/pdf_viewer.css\";\nimport \"pdfjs-dist/build/pdf.worker.mjs\";\nimport { getDocument } from \"pdfjs-dist/build/pdf\";\nimport { Streamlit } from \"streamlit-component-lib\";\nimport * as pdfjsLib from \"pdfjs-dist\";\nimport { debounce } from 'lodash';\n\nconst CMAP_URL = \"pdfjs-dist/cmaps/\";\nconst CMAP_PACKED = true;\nconst ENABLE_XFA = true;\nconst acceptedBorderStyleAttributes = ['solid', 'dashed', 'dotted', 'double', 'groove', 'ridge', 'inset', 'outset', 'none', undefined, null];\n\nexport default {\n props: [\"args\"],\n\n setup(props) {\n const totalHeight = ref(0);\n const maxWidth = ref(0);\n const pageScales = ref([]);\n const pageHeights = ref([]);\n const loadedPages = ref([]);\n const currentFrameHeight = ref(props.args.height || 0);\n\n const isRenderingAllPages = props.args.pages_to_render.length === 0;\n\n const renderText = props.args.render_text === true;\n\n const parseWidthValue = (widthValue, fallbackValue = window.innerWidth) => {\n if (typeof widthValue === \"string\" && widthValue.endsWith(\"%\")) {\n const num = parseFloat(widthValue)\n if (!isNaN(num)) {\n return { type: \"percent\", value: num / 100 }\n }\n }\n const numeric = Number(widthValue)\n if (!isNaN(numeric) && numeric > 0) {\n return { type: \"pixel\", value: numeric }\n }\n return { type: \"pixel\", value: fallbackValue }\n }\n\n const pdfContainerStyle = computed(() => {\n const result = parseWidthValue(props.args.width, window.innerWidth);\n const widthCSS = result.type === \"percent\" ? `${result.value * 100}%` : `${result.value}px`;\n return {\n width: widthCSS,\n height: props.args.height ? `${props.args.height}px` : 'auto',\n overflow: 'auto',\n position: 'relative',\n };\n });\n\n const pdfViewerStyle = { position: 'relative' };\n\n const calculatePdfsHeight = (page) => {\n let height = 0;\n if (isRenderingAllPages) {\n for (let i = 0; i < page - 1; i++) {\n height += pageHeights.value[i] * pageScales.value[i] + props.args.pages_vertical_spacing;\n }\n } else {\n for (let i = 0; i < pageHeights.value.length; i++) {\n if (props.args.pages_to_render.includes(i + 1) && i < page - 1) {\n height += pageHeights.value[i] * pageScales.value[i] + props.args.pages_vertical_spacing;\n }\n }\n }\n return height;\n };\n\n const clearExistingCanvases = (pdfViewer) => {\n if (!pdfViewer) return;\n pdfViewer.innerHTML = '';\n };\n\n const createCanvasForPage = (page, scale, rotation, pageNumber, resolutionRatioBoost = 1) => {\n const viewport = page.getViewport({ scale, rotation });\n const ratio = (window.devicePixelRatio || 1) * resolutionRatioBoost;\n\n const canvas = document.createElement(\"canvas\");\n canvas.id = `canvas_page_${pageNumber}`;\n canvas.height = viewport.height * ratio;\n canvas.width = viewport.width * ratio;\n canvas.style.width = `${viewport.width}px`;\n canvas.style.height = `${viewport.height}px`;\n canvas.style.display = \"block\";\n canvas.getContext(\"2d\").scale(ratio, ratio);\n\n return canvas;\n };\n\n const renderAnnotation = (annotation, annotationIndex, pageDiv, scale) => {\n const annotationDiv = document.createElement('div');\n annotation.id = `${annotation.id || annotationIndex}`\n annotationDiv.id = `annotation-${annotation.id}`;\n annotationDiv.setAttribute(\"data-index\", annotation.id);\n annotationDiv.style.position = 'absolute';\n annotationDiv.style.left = `${annotation.x * scale}px`;\n annotationDiv.style.top = `${annotation.y * scale}px`;\n annotationDiv.style.width = `${annotation.width * scale}px`;\n annotationDiv.style.height = `${annotation.height * scale}px`;\n let border = annotation.border\n if (!annotation.border || !acceptedBorderStyleAttributes.includes(annotation.border)) {\n border = \"solid\"\n }\n annotationDiv.style.outline = `${props.args.annotation_outline_size * scale}px ${border} ${annotation.color}`;\n annotationDiv.style.cursor = renderText ? 'text' : 'pointer';\n annotationDiv.style.pointerEvents = renderText ? 'none' : 'auto';\n annotationDiv.style.zIndex = 10;\n\n if (!renderText) {\n annotationDiv.addEventListener('click', () => {\n Streamlit.setComponentValue({\n clicked_annotation: { index: annotation.id, ...annotation },\n });\n });\n }\n\n pageDiv.appendChild(annotationDiv);\n };\n\n const renderPage = async (page, canvas, viewport, annotations, annotationCount) => {\n const renderContext = {\n canvasContext: canvas.getContext(\"2d\"),\n viewport: viewport\n };\n\n await page.render(renderContext).promise;\n\n const pageDiv = document.createElement('div');\n pageDiv.className = 'page';\n pageDiv.style.position = 'relative';\n pageDiv.style.width = `${viewport.width}px`;\n pageDiv.style.height = `${viewport.height}px`;\n pageDiv.style.marginBottom = `${props.args.pages_vertical_spacing}px`;\n\n const canvasWrapper = document.createElement('div');\n canvasWrapper.className = 'canvasWrapper';\n canvasWrapper.style.position = 'absolute';\n canvasWrapper.style.top = '0';\n canvasWrapper.style.left = '0';\n canvasWrapper.appendChild(canvas);\n\n pageDiv.appendChild(canvasWrapper);\n\n if (renderText) {\n const textContent = await page.getTextContent();\n const textLayerDiv = document.createElement(\"div\");\n textLayerDiv.className = \"textLayer\";\n textLayerDiv.style.zIndex = \"11\";\n textLayerDiv.style.position = 'absolute';\n textLayerDiv.style.top = '0';\n textLayerDiv.style.left = '0';\n textLayerDiv.style.height = `${viewport.height}px`;\n textLayerDiv.style.width = `${viewport.width}px`;\n\n const textLayer = new pdfjsLib.TextLayer({\n textContentSource: textContent,\n container: textLayerDiv,\n viewport: viewport,\n textDivs: []\n });\n await textLayer.render();\n\n pageDiv.appendChild(textLayerDiv);\n }\n\n if (annotations && annotations.length > 0) {\n annotations.forEach((annotation, index) => {\n const annotationUniqueIndex = annotationCount + index\n renderAnnotation(annotation, annotationUniqueIndex, pageDiv, viewport.scale);\n });\n }\n\n const pdfViewer = document.getElementById(\"pdfViewer\");\n pdfViewer.appendChild(pageDiv);\n };\n\n const getPagesToRender = (numPages) => {\n if (props.args.pages_to_render.length === 0) {\n return Array.from({ length: numPages }, (_, i) => i + 1);\n }\n return props.args.pages_to_render;\n };\n\n const renderPdfPages = async (pdf, pdfViewer, pagesToRender) => {\n totalHeight.value = 0;\n pageScales.value = [];\n pageHeights.value = [];\n loadedPages.value = [];\n\n const resolutionBoost = props.args.resolution_boost || 1;\n\n let annotationCount = 0;\n\n for (let pageNumber = 1; pageNumber <= pdf.numPages; pageNumber++) {\n const page = await pdf.getPage(pageNumber);\n const rotation = page.rotate;\n const unscaledViewport = page.getViewport({ scale: 1.0, rotation });\n\n if (props.args.height > 0) {\n const widthScale = unscaledViewport.width / unscaledViewport.height;\n const possibleScaledWidth = widthScale * props.args.height;\n if (maxWidth.value === 0 || possibleScaledWidth < maxWidth.value) {\n maxWidth.value = possibleScaledWidth;\n }\n }\n\n const scale = maxWidth.value / unscaledViewport.width;\n\n pageScales.value.push(scale);\n pageHeights.value.push(unscaledViewport.height);\n\n if (pagesToRender.includes(pageNumber)) {\n const canvas = createCanvasForPage(page, scale, rotation, pageNumber, resolutionBoost);\n pdfViewer.style.setProperty('--scale-factor', scale);\n\n const viewport = page.getViewport({\n scale: scale,\n rotation: rotation,\n intent: \"print\",\n });\n\n const annotationsForPage = props.args.annotations.filter(\n anno => Number(anno.page) === pageNumber\n );\n\n totalHeight.value += canvas.height / ((window.devicePixelRatio || 1) * resolutionBoost);\n await renderPage(page, canvas, viewport, annotationsForPage, annotationCount);\n annotationCount += annotationsForPage.length\n\n if (canvas.id) {\n loadedPages.value.push(canvas.id);\n }\n }\n }\n // Subtract the margin for the last page as it's not needed\n if (pagesToRender.length > 0) {\n totalHeight.value -= props.args.pages_vertical_spacing;\n }\n };\n\n const alertError = (error) => {\n console.error(error);\n window.alert(error.message);\n };\n\n const loadPdfs = async (url) => {\n pdfjsLib.GlobalWorkerOptions.workerSrc = 'pdfjs-dist/build/pdf.worker.mjs';\n try {\n const loadingTask = getDocument({\n url: url,\n cMapUrl: CMAP_URL,\n cMapPacked: CMAP_PACKED,\n enableXfa: ENABLE_XFA,\n });\n const pdf = await loadingTask.promise;\n\n const pdfViewer = document.getElementById(\"pdfViewer\");\n clearExistingCanvases(pdfViewer);\n\n const pagesToRender = getPagesToRender(pdf.numPages);\n await renderPdfPages(pdf, pdfViewer, pagesToRender);\n scrollToItem();\n } catch (error) {\n alertError(error);\n }\n };\n\n const scrollToItem = () => {\n if (props.args.scroll_to_page) {\n const page = document.getElementById(`canvas_page_${props.args.scroll_to_page}`);\n if (page) {\n page.scrollIntoView({ behavior: \"smooth\" });\n }\n } else if (props.args.scroll_to_annotation) {\n const annotation = document.querySelector(`[id^=\"annotation-\"][data-index=\"${props.args.scroll_to_annotation}\"]`);\n if (annotation) {\n annotation.scrollIntoView({ behavior: \"smooth\", block: \"center\" });\n }\n }\n };\n\n const setFrameHeight = () => {\n const newHeight = props.args.height || totalHeight.value;\n if (newHeight !== currentFrameHeight.value) {\n Streamlit.setFrameHeight(newHeight);\n currentFrameHeight.value = newHeight;\n }\n };\n\n const setFrameWidth = () => {\n const result = parseWidthValue(props.args.width, window.innerWidth);\n let newMaxWidth;\n if (result.type === \"percent\") {\n newMaxWidth = Math.min(Math.floor(result.value * window.innerWidth), window.innerWidth);\n } else {\n newMaxWidth = Math.min(result.value, window.innerWidth);\n }\n\n if (newMaxWidth !== maxWidth.value) {\n maxWidth.value = newMaxWidth;\n }\n };\n\n const handleResize = async () => {\n try {\n console.log('handleResize');\n if (props.args.rendering === \"unwrap\") {\n const binaryDataUrl = `data:application/pdf;base64,${props.args.binary}`;\n setFrameWidth();\n await loadPdfs(binaryDataUrl);\n setFrameHeight();\n }\n } catch (error) {\n console.error(error);\n }\n };\n\n // Debounced resize handler to prevent multiple rapid executions\n const debouncedHandleResize = debounce(handleResize, 200);\n\n onMounted(() => {\n debouncedHandleResize();\n window.addEventListener(\"resize\", debouncedHandleResize);\n });\n\n onUnmounted(() => {\n window.removeEventListener(\"resize\", debouncedHandleResize);\n });\n\n return {\n pdfContainerStyle,\n pdfViewerStyle,\n };\n },\n};\n</script>\n","import { render } from \"./PdfViewer.vue?vue&type=template&id=0969f1e4\"\nimport script from \"./PdfViewer.vue?vue&type=script&lang=js\"\nexport * from \"./PdfViewer.vue?vue&type=script&lang=js\"\n\nimport exportComponent from \"../node_modules/vue-loader/dist/exportHelper.js\"\nconst __exports__ = /*#__PURE__*/exportComponent(script, [['render',render]])\n\nexport default __exports__","import { createElementVNode as _createElementVNode, toDisplayString as _toDisplayString, openBlock as _openBlock, createElementBlock as _createElementBlock, createCommentVNode as _createCommentVNode, renderSlot as _renderSlot } from \"vue\"\n\nconst _hoisted_1 = { key: 0 }\nconst _hoisted_2 = { class: \"err__msg\" }\n\nexport function render(_ctx: any,_cache: any,$props: any,$setup: any,$data: any,$options: any) {\n return (_openBlock(), _createElementBlock(\"div\", null, [\n (_ctx.componentError != '')\n ? (_openBlock(), _createElementBlock(\"div\", _hoisted_1, [\n _cache[0] || (_cache[0] = _createElementVNode(\"h1\", { class: \"err__title\" }, \"Component Error\", -1)),\n _createElementVNode(\"div\", _hoisted_2, \"Message: \" + _toDisplayString(_ctx.componentError), 1)\n ]))\n : (_ctx.renderData != null)\n ? _renderSlot(_ctx.$slots, \"default\", {\n key: 1,\n args: _ctx.renderData.args,\n disabled: _ctx.renderData.disabled\n }, undefined, true)\n : _createCommentVNode(\"\", true)\n ]))\n}","<template>\n <div>\n <!-- Error boundary. If our wrapped component threw an error, display it. -->\n <div v-if=\"componentError != ''\">\n <h1 class=\"err__title\">Component Error</h1>\n <div class=\"err__msg\">Message: {{ componentError }}</div>\n </div>\n <!-- \n Else render the component slot and pass Streamlit event data in `args` props to it.\n Don't render until we've gotten our first RENDER_EVENT from Streamlit.\n All components get disabled while the app is being re-run, and become re-enabled when the re-run has finished.\n -->\n <slot\n v-else-if=\"renderData != null\"\n :args=\"renderData.args\"\n :disabled=\"renderData.disabled\"\n ></slot>\n </div>\n</template>\n\n<script lang=\"ts\">\nimport {\n ref,\n defineComponent,\n onMounted,\n onUpdated,\n onUnmounted,\n onErrorCaptured,\n} from \"vue\"\nimport { Streamlit, RenderData } from \"streamlit-component-lib\"\n\nexport default defineComponent({\n name: \"WithStreamlitConnection\",\n setup() {\n const renderData = ref<RenderData>((undefined as unknown) as RenderData)\n const componentError = ref(\"\")\n\n const onRenderEvent = (event: Event): void => {\n const renderEvent = event as CustomEvent<RenderData>\n renderData.value = renderEvent.detail\n componentError.value = \"\"\n }\n\n // Set up event listeners, and signal to Streamlit that we're ready.\n // We won't render the component until we receive the first RENDER_EVENT.\n onMounted(() => {\n Streamlit.events.addEventListener(Streamlit.RENDER_EVENT, onRenderEvent)\n Streamlit.setComponentReady()\n })\n onUpdated(() => {\n // If our slot threw an error, we display it in render(). In this\n // case, the slot won't be mounted and therefore won't call\n // `setFrameHeight` on its own. We do it here so that the rendered\n // error will be visible.\n if (componentError.value != \"\") {\n Streamlit.setFrameHeight()\n }\n })\n onUnmounted(() => {\n Streamlit.events.removeEventListener(\n Streamlit.RENDER_EVENT,\n onRenderEvent\n )\n })\n onErrorCaptured(err => {\n componentError.value = String(err)\n })\n\n return {\n renderData,\n componentError,\n }\n },\n})\n</script>\n\n<style scoped>\n.err__title,\n.err__msg {\n margin: 0;\n}\n</style>\n","import { render } from \"./WithStreamlitConnection.vue?vue&type=template&id=bef81972&scoped=true&ts=true\"\nimport script from \"./WithStreamlitConnection.vue?vue&type=script&lang=ts\"\nexport * from \"./WithStreamlitConnection.vue?vue&type=script&lang=ts\"\n\nimport \"./WithStreamlitConnection.vue?vue&type=style&index=0&id=bef81972&scoped=true&lang=css\"\n\nimport exportComponent from \"../../node_modules/vue-loader/dist/exportHelper.js\"\nconst __exports__ = /*#__PURE__*/exportComponent(script, [['render',render],['__scopeId',\"data-v-bef81972\"]])\n\nexport default __exports__","import { render } from \"./App.vue?vue&type=template&id=6ea7f320&ts=true\"\nimport script from \"./App.vue?vue&type=script&lang=ts\"\nexport * from \"./App.vue?vue&type=script&lang=ts\"\n\nimport \"./App.vue?vue&type=style&index=0&id=6ea7f320&lang=css\"\n\nimport exportComponent from \"../node_modules/vue-loader/dist/exportHelper.js\"\nconst __exports__ = /*#__PURE__*/exportComponent(script, [['render',render]])\n\nexport default __exports__","import { createApp } from 'vue'\nimport App from './App.vue'\n\ncreateApp(App).mount('#app')\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\tid: moduleId,\n\t\tloaded: false,\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n\t// Flag the module as loaded\n\tmodule.loaded = true;\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n// expose the modules object (__webpack_modules__)\n__webpack_require__.m = __webpack_modules__;\n\n","var deferred = [];\n__webpack_require__.O = (result, chunkIds, fn, priority) => {\n\tif(chunkIds) {\n\t\tpriority = priority || 0;\n\t\tfor(var i = deferred.length; i > 0 && deferred[i - 1][2] > priority; i--) deferred[i] = deferred[i - 1];\n\t\tdeferred[i] = [chunkIds, fn, priority];\n\t\treturn;\n\t}\n\tvar notFulfilled = Infinity;\n\tfor (var i = 0; i < deferred.length; i++) {\n\t\tvar [chunkIds, fn, priority] = deferred[i];\n\t\tvar fulfilled = true;\n\t\tfor (var j = 0; j < chunkIds.length; j++) {\n\t\t\tif ((priority & 1 === 0 || notFulfilled >= priority) && Object.keys(__webpack_require__.O).every((key) => (__webpack_require__.O[key](chunkIds[j])))) {\n\t\t\t\tchunkIds.splice(j--, 1);\n\t\t\t} else {\n\t\t\t\tfulfilled = false;\n\t\t\t\tif(priority < notFulfilled) notFulfilled = priority;\n\t\t\t}\n\t\t}\n\t\tif(fulfilled) {\n\t\t\tdeferred.splice(i--, 1)\n\t\t\tvar r = fn();\n\t\t\tif (r !== undefined) result = r;\n\t\t}\n\t}\n\treturn result;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.g = (function() {\n\tif (typeof globalThis === 'object') return globalThis;\n\ttry {\n\t\treturn this || new Function('return this')();\n\t} catch (e) {\n\t\tif (typeof window === 'object') return window;\n\t}\n})();","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","__webpack_require__.nmd = (module) => {\n\tmodule.paths = [];\n\tif (!module.children) module.children = [];\n\treturn module;\n};","// no baseURI\n\n// object to store loaded and loading chunks\n// undefined = chunk not loaded, null = chunk preloaded/prefetched\n// [resolve, reject, Promise] = chunk loading, 0 = chunk loaded\nvar installedChunks = {\n\t524: 0\n};\n\n// no chunk on demand loading\n\n// no prefetching\n\n// no preloaded\n\n// no HMR\n\n// no HMR manifest\n\n__webpack_require__.O.j = (chunkId) => (installedChunks[chunkId] === 0);\n\n// install a JSONP callback for chunk loading\nvar webpackJsonpCallback = (parentChunkLoadingFunction, data) => {\n\tvar [chunkIds, moreModules, runtime] = data;\n\t// add \"moreModules\" to the modules object,\n\t// then flag all \"chunkIds\" as loaded and fire callback\n\tvar moduleId, chunkId, i = 0;\n\tif(chunkIds.some((id) => (installedChunks[id] !== 0))) {\n\t\tfor(moduleId in moreModules) {\n\t\t\tif(__webpack_require__.o(moreModules, moduleId)) {\n\t\t\t\t__webpack_require__.m[moduleId] = moreModules[moduleId];\n\t\t\t}\n\t\t}\n\t\tif(runtime) var result = runtime(__webpack_require__);\n\t}\n\tif(parentChunkLoadingFunction) parentChunkLoadingFunction(data);\n\tfor(;i < chunkIds.length; i++) {\n\t\tchunkId = chunkIds[i];\n\t\tif(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) {\n\t\t\tinstalledChunks[chunkId][0]();\n\t\t}\n\t\tinstalledChunks[chunkId] = 0;\n\t}\n\treturn __webpack_require__.O(result);\n}\n\nvar chunkLoadingGlobal = self[\"webpackChunkstreamlit_pdf_viewer\"] = self[\"webpackChunkstreamlit_pdf_viewer\"] || [];\nchunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0));\nchunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal));","// startup\n// Load entry module and return exports\n// This entry module depends on other loaded chunks and execution need to be delayed\nvar __webpack_exports__ = __webpack_require__.O(undefined, [504], () => (__webpack_require__(9973)))\n__webpack_exports__ = __webpack_require__.O(__webpack_exports__);\n"],"names":["_hoisted_1","id","render","_ctx","_cache","$props","$setup","$data","$options","_component_PdfViewer","_resolveComponent","_component_WithStreamlitConnection","_openBlock","_createElementBlock","_createVNode","default","_withCtx","args","_","style","_normalizeStyle","pdfContainerStyle","rendering","_createElementVNode","pdfViewerStyle","_hoisted_2","src","binary","width","height","type","_hoisted_4","_hoisted_6","CMAP_URL","CMAP_PACKED","ENABLE_XFA","acceptedBorderStyleAttributes","undefined","props","setup","totalHeight","ref","maxWidth","pageScales","pageHeights","loadedPages","currentFrameHeight","renderText","pages_to_render","length","render_text","parseWidthValue","widthValue","fallbackValue","window","innerWidth","endsWith","num","parseFloat","isNaN","value","numeric","Number","computed","result","widthCSS","overflow","position","clearExistingCanvases","pdfViewer","innerHTML","createCanvasForPage","page","scale","rotation","pageNumber","resolutionRatioBoost","viewport","getViewport","ratio","devicePixelRatio","canvas","document","createElement","display","getContext","renderAnnotation","annotation","annotationIndex","pageDiv","annotationDiv","setAttribute","left","x","top","y","border","includes","outline","annotation_outline_size","color","cursor","pointerEvents","zIndex","addEventListener","Streamlit","setComponentValue","clicked_annotation","index","appendChild","renderPage","async","annotations","annotationCount","renderContext","canvasContext","promise","className","marginBottom","pages_vertical_spacing","canvasWrapper","textContent","getTextContent","textLayerDiv","textLayer","pdfjsLib","textContentSource","container","textDivs","forEach","annotationUniqueIndex","getElementById","getPagesToRender","numPages","Array","from","i","renderPdfPages","pdf","pagesToRender","resolutionBoost","resolution_boost","getPage","rotate","unscaledViewport","widthScale","possibleScaledWidth","push","setProperty","intent","annotationsForPage","filter","anno","alertError","error","console","alert","message","loadPdfs","workerSrc","loadingTask","getDocument","url","cMapUrl","cMapPacked","enableXfa","scrollToItem","scroll_to_page","scrollIntoView","behavior","scroll_to_annotation","querySelector","block","setFrameHeight","newHeight","setFrameWidth","newMaxWidth","Math","min","floor","handleResize","log","binaryDataUrl","debouncedHandleResize","debounce","onMounted","onUnmounted","removeEventListener","__exports__","key","class","componentError","_toDisplayString","renderData","_renderSlot","$slots","disabled","_createCommentVNode","defineComponent","name","onRenderEvent","event","renderEvent","detail","events","RENDER_EVENT","setComponentReady","onUpdated","onErrorCaptured","err","String","components","PdfViewer","WithStreamlitConnection","createApp","App","mount","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","exports","module","loaded","__webpack_modules__","call","m","deferred","O","chunkIds","fn","priority","notFulfilled","Infinity","fulfilled","j","Object","keys","every","splice","r","d","definition","o","defineProperty","enumerable","get","g","globalThis","this","Function","e","obj","prop","prototype","hasOwnProperty","nmd","paths","children","installedChunks","chunkId","webpackJsonpCallback","parentChunkLoadingFunction","data","moreModules","runtime","some","chunkLoadingGlobal","self","bind","__webpack_exports__"],"sourceRoot":""}
|