Use font without include or install them
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.
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.
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
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
Re: Use font without include or install them
Hi again,
Thanks for the answer !
I've try to use this method, but it don't works in my case. This is what i've done :
In java :
StiFontCollection.addResourceFont("testfont", FileUtils.readFileToByteArray(new File(C:\times.ttf)), "ttf");
{...}
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 !
Thanks for the answer !
I've try to use this method, but it don't works in my case. This is what i've done :
In java :
StiFontCollection.addResourceFont("testfont", FileUtils.readFileToByteArray(new File(C:\times.ttf)), "ttf");
{...}
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 !
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...))
In report you must use font name that described in font file (not in name addResourceFont(String name...))
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.
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.
Re: Use font without include or install them
Hello.
We use next code
StiFontCollection.addResourceFont("testfont", FileUtils.readFileToByteArray(new File("C:/234/Wolf in the City.ttf")), "ttf");
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"
We use next code
StiFontCollection.addResourceFont("testfont", FileUtils.readFileToByteArray(new File("C:/234/Wolf in the City.ttf")), "ttf");
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"
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 ?
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 ?
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.
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.
Re: Use font without include or install them
Thanks you Vadim, you answer my question.
Subject's closed !
Subject's closed !
-
- Posts: 6271
- Joined: Tue Mar 20, 2018 5:34 am
Re: Use font without include or install them
Hello,
You are welcome.
You are welcome.