[]
        
(Showing Draft Content)

Embedding Fonts

Font embedding feature available in FlexReport, allows you to embed default or preinstalled fonts in the reports or .flxr files. Now, when that file is loaded on a different system, fonts that have been used or embedded while designing of file is ensured to render correctly on another system. Embedding of fonts in FlexReport is done using the Save(string fileName, bool embedImages, bool embedSubReports, bool saveAll = false, FontEmbedType embedFonts = FontEmbedType.Auto) method available in FlexReport class. The description of parameters of the Save method used for embedding the font in report is as follows:

  • fileName: Enables you to specify the full name of the file to be created (if the file already exists, it will be overwritten).
  • embedImages: Enables you to embed images into the output. It can be set to a boolean value i.e. either true or false.
  • embedSubReports: Enables you to embed subreports into the output file. It can be set to boolean value i.e. either true or false.
  • saveAll: Enables you to save all reports. It can be set to a boolean value i.e. either true or false.
  • embedFonts: Enables you to embed fonts into the output file. It can be set to values Auto or None using FontEmbedType enum. To embed the fonts in the document, you need to set the value of embedFonts as FontEmbedType.Auto.

type=note

If the value of saveAll parameter is set to true then FontEmbedType.Auto does not work.

To embed fonts in a report, an object of the FlexReport class is created with the name report. Then, the report object calls the Load method to load the report. The Load method takes two arguments i.e. fileName and reportName to load a report from the file. After embedding fonts in the file, the file is then saved with the name Result.flxr using the Save method. Following code snippet allows you to save the report with fonts embedded in it:

private void Save_File(object sender, RoutedEventArgs e)
{
    FlexReport report = new FlexReport();
    report.Load("Samplefont.flxr","New Report");
    report.Save("Result.flxr",true,true,false,FontEmbedType.Auto);
}