Fonts can be embedded into a report as resources so the document renders and exports identically regardless of the fonts installed on the server.

Embedding the font. In the report action, read the font file, add it as a StiResource, and register it in the font collection:
var fileContent = System.IO.File.ReadAllBytes(StiNetCoreHelper.MapPath(this, "Fonts/Roboto-Black.ttf"));
var resource = new StiResource("Roboto-Black", "Roboto-Black", false, StiResourceType.FontTtf, fileContent, false);
report.Dictionary.Resources.Add(resource);
StiFontCollection.AddResourceFont(resource.Name, resource.Content, "ttf", resource.Alias);

Using the font. Create the font from the collection and assign it to a component:
var dataText = new StiText();
dataText.ClientRectangle = new RectangleD(1, 1, 3, 2);
dataText.Text = "Sample Text";
dataText.Font = StiFontCollection.CreateFont("Roboto-Black", 12, FontStyle.Regular);
report.Pages[0].Components.Add(dataText);

Because the font travels inside the report, server-side exports such as PDF are pixel-perfect even on machines where the font is not installed — important for web applications running on servers with a minimal font set.

By using this website, you agree to the use of cookies for analytics and personalized content. Cookies store useful information on your computer to help us improve efficiency and usability. For more information, please read the privacy policy and cookie policy.