pdfium-lib icon indicating copy to clipboard operation
pdfium-lib copied to clipboard

The file does not display correctly

Open none18l opened this issue 4 years ago • 20 comments

hi,The below file does not display correctly in IPad,Do you konw the reason? Thank you!

1111.pdf

none18l avatar Sep 13 '21 09:09 none18l

Hi,

Maybe problems with fonts:

image

The fonts are embedded when you exported it?

paulocoutinhox avatar Sep 13 '21 23:09 paulocoutinhox

@paulo-coutinho – I have had the same experience with a Chinese-language PDF too. The font was supposed to be grabbed from the OS assuming a viewer with access to the fonts of the OS.

CetinSert avatar Sep 14 '21 13:09 CetinSert

@none18l do you have the fonts?

@cetinsert in my local pdf reader on macOS it works, so based on your message it need work on browser too, no?

paulocoutinhox avatar Sep 14 '21 14:09 paulocoutinhox

@paulo-coutinho I don't think PDFium bundles that many fonts. PDF spec mentions base 14 fonts. They would not have more in PDFium I believe. CJK fonts are larger in size and most likely not among the base 14. (There are also fonts with the same name that have fewer or more glyphs depending on how they are distributed.) Perhaps we can forward the issue to PDFium. Emscripten might provide a way to embed larger fonts in its emulated filesystem too.

CetinSert avatar Sep 14 '21 15:09 CetinSert

No fonts. but if PDFium have not the fonts,how can I set the default font that the systems have?

none18l avatar Sep 15 '21 11:09 none18l

I tested some pdfs with chinese fonts and it works. Maybe your problem is with your PDF fonts.

image image sample-ce-notice-chinese-trd.pdf Classical Chinese Sample 22208_0_8.pdf

paulocoutinhox avatar Sep 15 '21 16:09 paulocoutinhox

@none18l i recommend you read this:

https://www.eduhk.hk/ocio/content/faq-how-embed-asian-fonts-pdf-files and https://stackoverflow.com/questions/30083764/which-chinese-font-is-commonly-supported-by-pdf-readers-of-chinese-people

As i sad, you can embed fonts or it glyphs subset.

paulocoutinhox avatar Sep 15 '21 16:09 paulocoutinhox

@paulo-coutinho – here is another file that does not render correctly that does not involve CJK fonts.

https://lab.webpdf.dev/#src=//github.com/mozilla/pdf.js/files/4652174/fff.pdf image


🦊 PDF.js' original issue which contains a recent fix: https://github.com/mozilla/pdf.js/issues/11915

CetinSert avatar Sep 16 '21 19:09 CetinSert

@paulo-coutinho

After reviewing the changes closing https://github.com/mozilla/pdf.js/issues/11915, I have come to the conclusion that they might be out of scope of this repository should they require source code changes in PDFium itself.

Embedding fonts via the emulated file system of emscripten (which I assume exists) would still be interesting to look at. Should that path ever be taken, the most flexible solution for the WASM port would be to expose adding such system fonts to the developer of websites themselves.

  1. find out if PDFium proper checks a directory for system fonts
  2. find out if emscripten provides a file system emulation API to users
  3. document the directory (from 1) PDFium checks for system fonts
  4. find the emscripten file system API to add font files to the directory (from 3)

The above steps would ensure more cases just work and require no code changes in PDFium proper or the WASM port of it.

CetinSert avatar Sep 17 '21 03:09 CetinSert

Hi,

I will check it.

paulocoutinhox avatar Sep 17 '21 04:09 paulocoutinhox

another no-fonts file

  • https://lab.webpdf.dev/#src=//github.com/mozilla/pdf.js/files/1634833/E-WG18_105147.pdf
    🦊 https://github.com/mozilla/pdf.js/issues/9367

CetinSert avatar Sep 17 '21 20:09 CetinSert

There is anything that i can do from my side?

paulocoutinhox avatar Nov 05 '21 22:11 paulocoutinhox

Hi,

I launched a new version (4692).

To test, you can access: https://pdfviewer.github.io/

Can you check the docs/code to see if your problem still happen?

You can donate, if you want, to help the project.

Thanks.

paulocoutinhox avatar Nov 06 '21 04:11 paulocoutinhox

No changes with 4692

  1. https://github.com/paulo-coutinho/pdfium-lib/issues/48#issue-994678409 → https://lab.webpdf.dev/#src=//github.com/paulo-coutinho/pdfium-lib/files/7153228/1111.pdf – same with 4692 image
  2. https://github.com/paulo-coutinho/pdfium-lib/issues/48#issuecomment-921164020 – same
    image
  3. https://github.com/paulo-coutinho/pdfium-lib/issues/48#issuecomment-922068059 – same
    image

The situation will only improve if we bundle PDFium with fonts.
PDF.js does call such files broken and not spend developer time on them though.

CetinSert avatar Nov 06 '21 05:11 CetinSert

Hi

I don't understand. How PDF.js get these files and show correctly?

Thanks.

paulocoutinhox avatar Nov 15 '21 05:11 paulocoutinhox

@paulo-coutinho they bundle fonts: https://github.com/mozilla/pdf.js/tree/master/external/standard_fonts (funnily enough from PDFium upstream)

CetinSert avatar Nov 15 '21 10:11 CetinSert

Also, they refer to some likely not included ones that browsers might make available: https://github.com/mozilla/pdf.js/blob/e4f97a2a911a538be094fda434a216454690ea04/src/core/standard_fonts.js#L147 (these are more likely to have CJK glyphs)

CetinSert avatar Nov 15 '21 10:11 CetinSert

Some PDF files need external fonts to render, and WASM in browsers doesn't have the ability to access native files. I have managed to produce a version which will fetch fonts via HTTP requests if necessary (i.e., use HTTP Resources instead of local file system), but I am not sure if my company would like to let me open the solution yet.

KDr2 avatar Dec 09 '21 10:12 KDr2

@KDr2 feel free to create a PR with all patchs to make it work. @cetinsert what you think? we need download all that fonts and embed? that fonts are free?

paulocoutinhox avatar Dec 29 '21 06:12 paulocoutinhox

@KDr2 – please create a PR, you may omit the font files or commit them as empty (0-byte). Should a full PR be difficult, please provide guidance on the necessary adjustments we would have to replicate on our own. We will independently confirm the licensing requirements.

CetinSert avatar Dec 29 '21 08:12 CetinSert

Hi,

All problems was fixed in new release.

You can check here: https://github.com/paulocoutinhox/pdfium-lib/releases/tag/5407

The demo is here: https://pdfviewer.github.io/

I don't know if it still relevant. If anyone have a solution, please reopen and/or send the way to fix this.

Feel free to donate to help project development.

Thanks.

paulocoutinhox avatar Nov 08 '22 18:11 paulocoutinhox