Skip to content

Commit

Permalink
Merge pull request #63 from lfoppiano/fix-problem-with-chrome
Browse files Browse the repository at this point in the history
Fix issues with text layers that are arising with Chrome and tabs (or extenders)
  • Loading branch information
lfoppiano authored Sep 18, 2024
2 parents a96da5b + 4ace6a2 commit 05e7b73
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 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-rc0"
current_version = "0.0.18-rc2"
commit = "true"
tag = "true"
tag_name = "v{new_version}"
Expand Down
14 changes: 14 additions & 0 deletions streamlit_pdf_viewer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,3 +210,17 @@ def pdf_viewer(input: Union[str, Path, bytes],
scroll_to_annotation=2
)


## Issue with Chrome

# from glob import glob
#
# # paths = glob("/Users/lfoppiano/kDrive/library/articles/materials informatics/polymers/*.pdf")
# paths = glob("/Users/lfoppiano/development/projects/alirahelth/data/articles/*.pdf")
# for id, (tab, path) in enumerate(zip(st.tabs(paths),paths)):
# with tab:
# with st.container(height=600):
# if id == 0:
# pdf_viewer(path, width=500, render_text=True)
# else:
# pdf_viewer(path, width=1000, render_text=True)
2 changes: 1 addition & 1 deletion streamlit_pdf_viewer/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"dependencies": {
"core-js": "^3.6.5",
"pdfjs-dist": "^4.5.136",
"pdfjs-dist": "4.3.136",
"streamlit-component-lib": "^2.0.0",
"vue": "^3.0.0-0"
},
Expand Down
13 changes: 11 additions & 2 deletions streamlit_pdf_viewer/frontend/src/PdfViewer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,17 @@ export default {
canvasContext: canvas.getContext("2d"),
viewport: viewport
};
const renderTask = page.render(renderContext);
await renderTask.promise;
try {
const renderTask = page.render(renderContext);
await renderTask.promise.catch(function(error){
// alertError(error);
// do nothing
});
} catch (e) {
// do nothing
}
if (renderText) {
const textContent = await page.getTextContent();
Expand Down

0 comments on commit 05e7b73

Please sign in to comment.