mozilla / pdf.js

PDF Reader in JavaScript
https://mozilla.github.io/pdf.js/
Apache License 2.0
48.34k stars 9.97k forks source link

Text not shown properly, possibly a font problem #11151

Closed hveit closed 3 years ago

hveit commented 5 years ago

The attached PDF file does not show properly, when rendered with PDF.js. The console log shows fonts warnings. I am not sure if this is a problem in the PDF file or in PDF.js.

Attach (recommended) or Link to PDF file here: 937-Unfall.pdf

Configuration:

Steps to reproduce the problem:

  1. Upload and open the attached PDF file to PDF.js Demo on https://mozilla.github.io/pdf.js/web/viewer.html
  2. Some text is out of place, too large, possibly due to wrong font used

What is the expected behavior? (add screenshot) Google Chrome seems to render text correctly: ScreenshotChrome

As does Adobe Acrobat Reader DC: ScreenshotAcrobatReader

What went wrong? (add screenshot) Some text is out of place, too large: ScreenshotPDFJSOnlineDemo

Browser console log shows font warnings: ScreenshotConsoleWarning

Link to a viewer (if hosted on a site other than mozilla.github.io/pdf.js or as Firefox/Chrome extension):

timvandermeij commented 5 years ago

Closing since this is a duplicate of #7367 where not being able to load the fonts for AcroForms causes font substitution.

THausherr commented 5 years ago

I looked at field "4006" (Bearbeiter) and that one doesn't have an appearance stream. /NeedAppearances is set so the viewer should create it. /DA is "/QuickPDFF3ce08b65 10 Tf 0 0 0 rg" and the font "QuickPDFF3ce08b65" is available in the AcroForm default resources and fully embedded ("Root/AcroForm/DR/Font/QuickPDFF3ce08b65/FontDescriptor/FontFile2") so no font substitution should be needed.

Thus I wonder whether PDF.js looks at the AcroForm default resources.

hveit commented 5 years ago

@THausherr thanks for your analysis. So this issue doesn't seem to be a duplicate of issue #7367 after all and thus should be reopened? Unfortunately I do not seem to be able to do this here...

THausherr commented 5 years ago

Yeah IMHO this should be reopened. Alternatively a look / explanation whether PDF.js uses the fonts in AcroForm/DR/Font. @timvandermeij

timvandermeij commented 5 years ago

I have re-opened this since it seems to be a bit different, but I think the underlying cause is the same, namely that we don't do anything yet with the fonts from the AcroForm dictionary.

hveit commented 5 years ago

@timvandermeij thank you for clarifying.

escapewindow commented 4 years ago

This appears to be resolved if I set renderInteractiveForms to true.

hveit commented 4 years ago

This appears to be resolved if I set renderInteractiveForms to true.

This works for me as well: The font problem seems to disappear, setting this option to true. In this case all fields in my example PDF file are editable. This seems to be correct, since Adobe Acrobat reader shows it the same way. Now my question is: Is there some option/switch in PDF.js to show an AcroForm readonly, regardless of the readonly states of the fields within the PDF file? Something like a readonly mode for AcroForms? Or has something like this to be done always within the PDF file itself?

timvandermeij commented 3 years ago

Closing since this is fixed now with and without forms rendering, likely after #12828.