Page 1 of 1

Export pdf with embedded fonts

Posted: Mon Feb 13, 2023 4:37 pm
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

Re: Export pdf with embedded fonts

Posted: Mon Feb 13, 2023 7:13 pm
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.

Re: Export pdf with embedded fonts

Posted: Tue Feb 14, 2023 11:44 am
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 ?

Re: Export pdf with embedded fonts

Posted: Tue Feb 14, 2023 3:35 pm
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.