## Use font without include or install them

Stimulsoft Reports.Java discussion
Morgan-
Posts: 5
Joined: Mon Mar 01, 2021 10:17 am

### Use font without include or install them

Hello,
I have some reports to print both on Windows and Linux servers. For performances issues, i can’t include font inside the reports.
I found an option: public static void addResourceFont(java.lang.String p1, byte[] p2, java.lang.String p3). This option seems to allow using font without include them in the report and without installed them on the server.
But I didn’t found informations to use it. Someone know how to do that ?
Thanks you !
Version : 2020.4.1.
Posts: 273
Joined: Tue Apr 23, 2013 11:23 am

### Re: Use font without include or install them

Hello.

com.stimulsoft.base.StiFontCollection.addResourceFont(String name, byte[] content, String extension)

This method register font in LocalGraphicsEnvironment, you can use it by putting font file content into parameter byte[] content
Morgan-
Posts: 5
Joined: Mon Mar 01, 2021 10:17 am

### Re: Use font without include or install them

Hi again,
I've try to use this method, but it don't works in my case. This is what i've done :

In java :

{...}
StiExportManager.exportPdf(_reportStimulsoft, setting, byteArrayOutputStream);

In mrt file i've modified all font name in <Font></Font> by testfont.
like :
<Font>testfont,8</Font>

I have no error but the font in the pdf looks like a "default" font, not the one i defined.

What i've done wrong ?
Thanks you !
Posts: 273
Joined: Tue Apr 23, 2013 11:23 am

### Re: Use font without include or install them

Hello.

In report you must use font name that described in font file (not in name addResourceFont(String name...))
Morgan-
Posts: 5
Joined: Mon Mar 01, 2021 10:17 am

### Re: Use font without include or install them

I’ve try with this font: https://www.dafont.com/fr/wolf-in-the-city.font
In the font file, the name is “Wolf in the City”.
In mrt file, i've modified all font name in <Font></Font> by Wolf in the City
Like:
<Font>Wolf in the City, 8</Font>
The font in the generated pdf file is not the “Wolf in the City”.

Any idea? Any option to enable or disable?
Thanks you.
Posts: 273
Joined: Tue Apr 23, 2013 11:23 am

### Re: Use font without include or install them

Hello.

We use next code
StiReport report2 = StiSerializeManager.deserializeReport(new FileInputStream("c:/234/font.mrt"));
report2.render();
StiExportManager.exportPdf(report2, new FileOutputStream("c:/234/out.pdf"));

Font in mrt is : <Font>Wolf in the City,8</Font>
And it works as expected, PDF exported with font "Wolf in the City"
Attachments
out.pdf
font.mrt
Morgan-
Posts: 5
Joined: Mon Mar 01, 2021 10:17 am

### Re: Use font without include or install them

Thanks you, i've find the issue.
I use the StiPdfExportSettings in my code and this one is EmbeddedFonts = true by default but i set him to false. That's why it's don't works.

If i set him to true that's works, but it's will include the font into the pdf and growth the size of the pdf ?

If i understand well, it's works like that :
EmbeddedFonts = false : i must install the font on the server
EmbeddedFonts = true : it will growth the size of the pdf by included the font

There is another way ? i must generate a lot of pdf so i can't include font in each of them, and i have to manage a lot of server, so i can't install manually each font on each servers.
I already use Compressed = true but pdf generate with font are still too big.

Any idea ?
Posts: 273
Joined: Tue Apr 23, 2013 11:23 am

### Re: Use font without include or install them

Hello.

If i set him to true that's works, but it's will include the font into the pdf and growth the size of the pdf ? - Yes.

To display font there is two ways: embedded this font into PDF or install font to system.
Morgan-
Posts: 5
Joined: Mon Mar 01, 2021 10:17 am