How to add fonts to change the PDF Export language?

1 Answer 956 Views
General Discussions Grid
CHIHPEI
Top achievements
Rank 2
Iron
Iron
Iron
CHIHPEI asked on 19 Jan 2022, 02:32 AM

Hi everyone,

I'm using the ASP.NET Core MVC Grid,

after I export the pdf file it cant show chinese character properly(as the provided picture),

export pdf

I'm aware of the langauge render on the html and pdf is in a different logic,

So how and where can I add a specific font in ASP.NET Core MVC Grid?

Can anyone provide an simple example?

1 Answer, 1 is accepted

Sort by
1
Accepted
Tsvetomir
Telerik team
answered on 21 Jan 2022, 11:48 AM

Hi, CHIHPEI,

If you would like to include a font that is not available via the standard library, you could add them as follows:

https://docs.telerik.com/kendo-ui/framework/drawing/pdf-output/embedded-fonts#unicode-and-embedded-fonts

I hope you find this helpful.

 

Kind regards,
Tsvetomir
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

CHIHPEI
Top achievements
Rank 2
Iron
Iron
Iron
commented on 24 Jan 2022, 06:36 AM

Hi Tsvetomir,

Thanks for the porivded link,

but it is not working

I've put the chinese font .ttf in the local path of  wwwroot/lib/font/kaiu.ttf

and in the .cshtml I've also import the .css file , show as below


@font-face {
    font-family: "DFKai-SB";
    src: url("/lib/font/kaiu.ttf") format("truetype");
}

What am I missing, or is anything thing that I could check?

Kind regards,

ChihPei

Tsvetomir
Telerik team
commented on 24 Jan 2022, 08:36 AM

The font-face CSS rule is used to define the font. To use it, you should add the following:

.k-widget {
  font-family: "DFKai-SB";
}

Let me know if the font is still not applied.

 

CHIHPEI
Top achievements
Rank 2
Iron
Iron
Iron
commented on 24 Jan 2022, 09:22 AM

Hi Tsvetomir,

I've tried it and it works!

Thanks for helping and the quick respond!

Tags
General Discussions Grid
Asked by
CHIHPEI
Top achievements
Rank 2
Iron
Iron
Iron
Answers by
Tsvetomir
Telerik team
Share this question
or