react-pdf: cannot show Chinese correctly

OS: MacOS 10.13.6 React-pdf version: 1.0.0-alpha.8 Description: I’m using react-pdf to display a pdf in react application. But it turns out Chinese cannot be displayed correctly. How to replicate issue including code snippet (if applies): My Code is this: <Document> <Page size="A4"> <View> <Text>联系人:高先生</Text> <Text>联系人:李先生</Text> </View> <View> <Text>联系方式:13029078956</Text> <Text>联系方式:15568703567</Text> </View> </View> </Page> </Document> So I was wondering if I can set charset somewhere, such as in <Document> or <Page> so it can support Chinese language.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 29 (8 by maintainers)

Most upvoted comments

Font fallback it’s on the roadmap (https://github.com/diegomura/react-pdf/issues/933) but not implemented yet. I’m close to finish it though

怎么解决的? 我register 了字体还是无效呀。Font.register(‘https://github.com/chenqing/ng-mini/blob/master/font/msyh.ttf’, { family: ‘Microsoft Yahei’ });

Mmm… latin chars and numbers should display well if the font have those glyphs (most of Chinese fonts has latin and numbers as far as I saw). At least it works with the example from above

I has resolved this problem, you should choose the correct .ttf file to render chinese char. Such as msyh.ttf. 😃