You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Inspect the rendered text and check the font family.
Notice that the font displayed is sans-serif, which is the default assigned by PDF.js.
What is the expected behavior?
The font family should match the one specified in the PDF document, such as Georgia or Times New Roman, instead of defaulting to sans-serif.
What went wrong?
After comparing the rendering in Adobe Acrobat and PDF.js, it was observed that PDF.js is extracting a different font family than expected. While Adobe Acrobat correctly renders the fonts as Georgia or Times New Roman, PDF.js defaults to sans-serif across all pages. This discrepancy indicates that PDF.js is not properly detecting or applying the embedded fonts from the PDF.
Link to a viewer
No response
Additional context
I have implemented a custom PDF viewer instead of using the default PDF.js viewer. However, I am utilizing PDF.js functionalities for text layer rendering and the annotation layer.
Regarding the screenshot, I intentionally included the search highlight to clearly showcase the font discrepancy. The canvas layer correctly renders the fonts, but when inspecting the text layer, it defaults to sans-serif instead of the expected font (e.g., Georgia or Times New Roman).
Additionally, when calling page.getTextContent(), the returned text content includes styles where the font is set to sans-serif. This suggests that PDF.js is not correctly extracting or applying the embedded fonts in the text layer.
Could you confirm whether this is the expected behavior?
If not, is there any recommended approach to ensure that the text layer correctly reflects the embedded fonts from the PDF?
Since no updates on this issue #19492 I had to re-create this new issue.
This discussion was converted from issue #19501 on February 17, 2025 08:08.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Attach (recommended) or Link to PDF file
adient-test (1).pdf
Web browser and its version
Chrome 133.0.6943.99
Operating system and its version
Mac Air M1 - MacOs 15.3
PDF.js version
v4.10.38
Is the bug present in the latest PDF.js version?
Yes
Is a browser extension
No
Steps to reproduce the problem
What is the expected behavior?
The font family should match the one specified in the PDF document, such as Georgia or Times New Roman, instead of defaulting to sans-serif.
What went wrong?
After comparing the rendering in Adobe Acrobat and PDF.js, it was observed that PDF.js is extracting a different font family than expected. While Adobe Acrobat correctly renders the fonts as Georgia or Times New Roman, PDF.js defaults to sans-serif across all pages. This discrepancy indicates that PDF.js is not properly detecting or applying the embedded fonts from the PDF.
Link to a viewer
No response
Additional context
I have implemented a custom PDF viewer instead of using the default PDF.js viewer. However, I am utilizing PDF.js functionalities for text layer rendering and the annotation layer.
Regarding the screenshot, I intentionally included the search highlight to clearly showcase the font discrepancy. The canvas layer correctly renders the fonts, but when inspecting the text layer, it defaults to sans-serif instead of the expected font (e.g., Georgia or Times New Roman).
Additionally, when calling page.getTextContent(), the returned text content includes styles where the font is set to sans-serif. This suggests that PDF.js is not correctly extracting or applying the embedded fonts in the text layer.
Could you confirm whether this is the expected behavior?
If not, is there any recommended approach to ensure that the text layer correctly reflects the embedded fonts from the PDF?
Since no updates on this issue #19492 I had to re-create this new issue.
Beta Was this translation helpful? Give feedback.
All reactions