pdfrx icon indicating copy to clipboard operation
pdfrx copied to clipboard

Can not render some text of pdf on iOS and Web

Open cuishijie1991 opened this issue 11 months ago • 4 comments

Hello, I used pdfrx: 1.0.101 (flutter 3.24.5) to render a pdf file below. And I use PdfPage.render() to get the image of a pdf page.```

There are some Chinese characters in the attached PDF, which can be displayed on the Android platform, but cannot be displayed on the iOS and web platforms. I want to understand the reason, please help me take a look at this issue. In the webDemo of the project I tested, Chinese characters also cannot be displayed, but I am not sure whether the latest dependency has fixed this problem. Thank you

货件1-FBA18VCDN3HT.pdf

Image Image

cuishijie1991 avatar Mar 19 '25 10:03 cuishijie1991

The reason is very easy. The PDF file uses two fonts (Helvetica and STSong-Light) which are not embedded in the file. With Adobe Acrobat on Windows, we can easily check the missing fonts:

Image

By default, pdfium searchs these fonts on OS's font directories and if they exist, it is used to render the texts. But if not exist, the texts are not correctly rendered.

Pdfrx.fontPaths is a mechanism to specify font directories on your app. But even with the API, you should prepare the fonts on your app somehow.

espresso3389 avatar Mar 19 '25 10:03 espresso3389

Ah, currently, on Web platform, font-path is not supported anyway :( Because Web browser does not have proper mechanism to access OS's directories, we should have some other mechanism to specify these missing fonts...

espresso3389 avatar Mar 19 '25 10:03 espresso3389

Thank you very much for your reply, it is very clear. However, I would like to ask you about the parsing logic of PDF fonts. On iOS, flutter_pdf_render can render these Chinese characters, but pdfrx cannot. I observed that for English fonts, both flutter_pdf_render and pdfrx perform fallback font replacement, and only flutter_pdf_render does it for Chinese characters. Can we set a fallback font for pdfrx? Is there any direction to start with?

Image Image

cuishijie1991 avatar Mar 20 '25 03:03 cuishijie1991

Ah, currently, on Web platform, font-path is not supported anyway :( Because Web browser does not have proper mechanism to access OS's directories, we should have some other mechanism to specify these missing fonts...

Is same as https://github.com/espresso3389/pdfrx/issues/140 ? Thanks for your reply, have a good day

cuishijie1991 avatar Mar 21 '25 03:03 cuishijie1991

Ah, this is actually a duplicate of #140.

espresso3389 avatar Jul 29 '25 18:07 espresso3389

So I want to close the issue and re-open #140. Anyway, I recently have a progress on the issue. See #140.

espresso3389 avatar Jul 29 '25 19:07 espresso3389