logo
small logo
  • Products
  • Buy
  • Support
  • About
  • Customer panel Support
    • en
    • de
    • JP
    • ZH
  • Home
  • /
  • Articles
  • /
  • Using fonts in reports without installing them
  • Report generators family FastReport brief review

    March 23, 2020

    Without reporting it is impossible to carry on business in any sphere of life. Bureaucracy

    read more
  • How to sort similar matrices through one-dimensional array on several pages in FastReport .NET

    September 22, 2021

    Let's say we have the task: to sort the matrix on the first page in

    read more
  • When is the best way to use a code report and when in frx format

    February 29, 2020

    As you probably know, reports in FastReport .NET can be created not only in a

    read more
  • How to create a sales receipt from WinForms application

    May 30, 2020

    Most likely every .NET developer started from Windows Forms applications. Countless number of such applications

    read more
  • How to display the footer page PageFooter only on the last page of the report

    May 15, 2020

    When you develop the same reports, or reports with the same bands, you can use

    read more

Using fonts in reports without installing them

April 27, 2022

Using fonts in reports without installing them

The demanding criteria for modern electronic reports are quite high — they must not only display the necessary information, but have a certain design, data format, and graphic content. A modern report is a complex document with design elements. The rapid development of report generators has increased the requirements for documents.

A particular font in a report can be a corporate requirement or a design element. Many report generator users would like to be able to use custom fonts. FastReport.NET allows you to do it! We are talking about TrueTypeFonts.

Now you don’t have to install fonts to use them in the report. You can add them to the report before building. Exporting a report to PDF format allows you to include custom fonts in your document. Let's look at an example of how to add ttf fonts to a report and how to export a report to PDF including these fonts.

//Let’s create a report
Report report = new Report();
//We get the files of the desired fonts from the folder
var fonts = Directory.GetFiles("Fonts");
//Each font is added to the report generator configuration
 foreach (var font in fonts)
 {
 Config.PrivateFontCollection.AddFontFile(font);
}
// Let’s load a report template that contains text objects with set fonts from the Fonts folder
report.Load(@"test.frx");
//Preparing a report
report.Prepare();
//Create an object for exporting to PDF and set the fonts to be included in the document
var export = new PDFExport
 {
 EmbeddingFonts = true
 };
//Let’s export the report
report.Export(export, File.Create(@"test.pdf"));

What’s about the report template? In order to use non-standard fonts when you create a report in the designer, you still need to install them in the system (double click on the ttf font). If you open a report template in a system where there are no fonts used in this template, you will see that the fonts have been replaced with standard ones. However, if you open the template in a text editor, you will see the actual font settings:

<TextObject Name="Text8" Left="359.1" Width="179.55" Height="18.9" 
Text="Roboto-Black.ttf" Font="Roboto Black, 10pt"/>

Thus, if you have a report template with fonts that are not installed in the system, you cannot edit it without losing the font settings, but you can build it and export it if these fonts are added to the FastReport.NET configuration.

Let's say we have a report template created on a system with installed fonts. In the code above, we are adding fonts to the configuration:

Fonts for adding to the configuration

Let's display the report before exporting it to PDF. Let's add a line “report.Show();”.This is what the fonts look like in the report:

Fonts in the finished report

This is what the fonts look like in a PDF document:

Displaying fonts in a PDF document

Thus, if you do not need to develop reports with non-standard fonts, but only display or export them, then you do not need to install these fonts in the system. This can be convenient if you distribute your reports with custom fonts.

about product buy
avatar
Dmitriy Fedyashov
Technical Writer
Fast Reports Team: Dmitriy Fedyashov - Technical Writer at Fast Reports
.NET FastReport Report

Add comment
logo
  • 800-985-8986 (English, US)
  • +4930568373928 (German)
  • +55 19 98147-8148 (Portuguese)
  • info@fast-report.com
  • 901 N Pitt Str #325 Alexandria VA 22314
  • Buy
  • Download
  • Documentation
  • Testimonials
  • How to uninstall
  • FAQ
  • Tutorial Video
  • Forum
  • Support SLA
  • Articles
  • Our News
  • Press about us
  • Resellers
  • Extended licensing
  • Contact us

© 1998-2023 by Fast Reports Inc.

  • Privacy Policy
  • Cookies Policy

Trustpilot
By clicking “Accept all, you agree Fast Reports can store cookies on your device and disclose information in accordance with our Cookie Policy.