-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Render Text issues when using tabs in Chrome #60
Comments
Hi @hamdi3, This is indeed weird. In one of the unit tests that I wrote I check also that the PDF on the second tab contains rendered text. 🤔 Nevertheless, I tried with a code similar to your and it looks working. I did a test with 3 pdf documents. How many do you load? The message |
I've tried again, whatever pdf I'm rendering in the selected tab, as the page loads, is the only one with rendered texts (I've tried it on all my pdfs iteratively so I'm sure it's not pdf Issue). I've tried it with 2-3-10-15-20 pdfs and had the same issue. I'm using Chrome Version 127.0.6533.89 and unfortunately can't test it on another browser, could this be a browser issue? |
OK. It's a problem with Chrome. 😭 |
First answer about the I'll look into the other part, maybe I need the help of @t29mato who's a JS and Chrome Guru! 😅 I'm trying to catch and ignore these exception when we call the page.render, but I'm surely doing something wrong: try {
const renderTask = page.render(renderContext);
await renderTask.promise.catch(function(error){
// alertError(error);
// do nothing
});
} catch (e) {
// do nothing
} |
@lfoppiano As always thanks for the hard work and support :) |
The PR mozilla/pdf.js#18283 added the feature to support browsers' user-configurable minimum font size. However, Google Chrome's minimum font size becomes 0 when using Streamlit's tab functionality. PDF.js implements the text dragging feature by overlaying transparent text on the PDF. But, when the font size is set to 0, there is no text to drag, causing the feature to fail. Codehttps://github.com/mozilla/pdf.js/pull/18283/files#diff-eb5220436f55f0c6ff687c15781981b323be818cb77e49d53d66f7f372f1f23dR475-R491 Temporary SolutionDowngrading to the version 4.3.136 which does not support the minimum font size, restores the drag-and-drop functionality. Additional InformationI want to explain why the custom pdf_viewer component works when RELEASE=FALSE. When RELEASE=FALSE, the JavaScript runs each time you click on a tab. This lets it correctly get the minimum font size, even in Google Chrome. But when RELEASE=TRUE, the JavaScript tries to get the minimum font size for all tabs as soon as the page loads, which can cause issues. |
@t29mato can you please try to make a patch that tries to force the text characters to be greater than zero? |
db7a26d |
@lfoppiano |
@lfoppiano Or am I misunderstanding something... |
mmm, maybe you pushed on a different branch than |
@lfoppiano |
Ok. I've released rc2, tested it works on Chome. @hamdi3 could you please try it? |
@hamdi3 if you have still problems, let us know, and feel free to reopen this issue. |
I've realized that when a pdf is run in tabs with
render_text
set toTrue
it would only work for the selcted tab as the page loadsWhen trying to inspect it on the browser I've seen the following warnings on the console (for each document except the first one):
As always thanks for the good work and support :)
The text was updated successfully, but these errors were encountered: