Export pdf with embedded fonts

Stimulsoft Reports.NET discussion
Post Reply
commit.sim
Posts: 10
Joined: Thu Jan 19, 2023 10:01 am

Export pdf with embedded fonts

Post by commit.sim »

Hi all.

I have a little problem when exporting my report to pdf and using embedded fonts options.

When exporting without it, the result is:

Image



Instead when exporting with embedded fonts:


Image

The font I've installed is a google font Montserrat:
https://fonts.google.com/specimen/Montserrat

...adding .mrt in attach, too.

[...]

Suspicious is, the fonts are compressed when embedded.
Are there some other options I can set to solve a problem?

Thanks in advance
Attachments
Report.mrt
(29.32 KiB) Downloaded 81 times
Max Shamanov
Posts: 786
Joined: Tue Sep 07, 2021 10:11 am

Re: Export pdf with embedded fonts

Post by Max Shamanov »

Hello,

Please clarify, are you exporting the report from the code or from the designer?
Also you can try to add font to report resources.

Thank you.
commit.sim
Posts: 10
Joined: Thu Jan 19, 2023 10:01 am

Re: Export pdf with embedded fonts

Post by commit.sim »

Hi Max, thanks for your replay.
I export from code. But exporting from the designer, i have the same problem.

So, how can i add the specific .ttf file (or font), inside report resources ?
Max Shamanov
Posts: 786
Joined: Tue Sep 07, 2021 10:11 am

Re: Export pdf with embedded fonts

Post by Max Shamanov »

Hello,

You can use the following code to add font to report resouces:

Code: Select all

var fileContent = System.IO.File.ReadAllBytes("Fonts/Roboto-Black.ttf");
            var resource = new StiResource("Roboto-Black", "Roboto-Black", false, StiResourceType.FontTtf, fileContent, false);
            report.Dictionary.Resources.Add(resource);
            
or this code to add font to StiFontCollection:

Code: Select all

Stimulsoft.Base.StiFontCollection.addOpentypeFontFile("calibri.ttf", "Calibri");
Thank you.
Post Reply