-
-
Notifications
You must be signed in to change notification settings - Fork 848
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
The text layer is not rendered with same font weight and color #650
Comments
I'm seeing the same thing. Text is off vertically. The generated spans in the text layer specify the font family from the pdf (g_d0_f3), but clearly it isn't being loaded. I'm using react-pdf@5.0.0 (pdfjs-dist@2.4.456) with create react app (uses react 16.13.1). It clearly is falling back to the sans-serif font-family, and likely positioning them incorrectly because of this. I had the same results with 4.2.0. Is that font-family even correct? The pdf.js text-only example does a little more work to turn this internal font key into a real font name.
|
It's not always possible to reuse embedded fonts from PDF to render the text layer. In such cases, PDF.js and React-PDF are using generic fonts (serif, sans-serif, monospace; depending on which is the most applicable) and scale it to match the original container for an okay experience of selection. Text layer is not meant to be rendered for anything else than accessibility and text selection purposes. |
What confused me most was that I was comparing to other libraries (react-pdf-viewer and the vanilla PDF.js web viewer) and they seemed to be rendering the text perfectly. But that wasn't really the case. They had simply provided css rules to make the text layer span color transparent. I was able to get a lot closer with some css that forces the
It seems that this should be default behavior or documented in the FAQ on the wiki. But what noticed was that PDF.js viewer and react-pdf-viewer and the PDF.js viewer seem to using the built in I'm curious should you really be halving the
|
I added PR 697. |
This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this issue will be closed in 14 days. |
This issue was closed because it has been stalled for 14 days with no activity. |
Before you start - checklist
Description
The text layer over the canvas, I changed the opacity of being transparent to
black
color. I disabled the canvas layer being drawn. I can see the text layer now, but the font-weight and font color are not the same as pdf. I know that the text layer is rendered separately and doesn't have to do anything with the canvas. So, I was wondering if we could somehow get these details for eachtextDiv
created on the text layer? The font-weight and color should be the same at least.Steps to reproduce
Disable the canvas by adding the following lines in
canvas.js
.CanvasRenderingContext2D.prototype.strokeText = () => {};
CanvasRenderingContext2D.prototype.fillText = () => {};
Additional _information
BEFORE
AFTER
Environment
Chrome
The text was updated successfully, but these errors were encountered: