Selectable embedded fonts
The EmbeddingFonts property of FastReport.Export.Pdf indicates whether to include fonts in the pdf. Is it possible to choose which fonts to incorporate?
For example, some of my reports give very small pdf, 8k without fonts while incorporating them, they occupy 80k. Besides, it's the Arial font that's incorporated. And it's no problem not to incorporate Arial (I guess there's a mapping to Helvetica in the pdf reader).
Or maybe, if this is not possible, how could I get a list of all the fonts used by a report, just before exporting to disable EmbeddingFonts if there are only standard fonts and enable EmbeddingFonts if there is an unknown font.
Is that possible?
Thank you.
For example, some of my reports give very small pdf, 8k without fonts while incorporating them, they occupy 80k. Besides, it's the Arial font that's incorporated. And it's no problem not to incorporate Arial (I guess there's a mapping to Helvetica in the pdf reader).
Or maybe, if this is not possible, how could I get a list of all the fonts used by a report, just before exporting to disable EmbeddingFonts if there are only standard fonts and enable EmbeddingFonts if there is an unknown font.
Is that possible?
Thank you.
This discussion has been closed.
Comments
Hello!
We can fully implement the ability to get a list of all report fonts before exporting and dynamically manage EmbeddingFonts. After loading the template (or after calling `Prepare()`), you can iterate through all report objects using `report.AllObjects`:
using System; using System.Collections.Generic; using System.Linq; using FastReport; using FastReport.Export.Pdf; using var report = new Report(); report.Load(“report.frx”); report.Prepare(); var standardPdfFonts = new HashSet<string>(StringComparer.OrdinalIgnoreCase) { “Arial”, ‘Helvetica’, “Times New Roman”, “Courier New” }; var usedFonts = report.AllObjects .OfType<TextObject>() .Select(t => t.Font.Name) .Distinct(StringComparer.OrdinalIgnoreCase) .ToList(); bool hasNonStandardFonts = usedFonts.Any(f => !standardPdfFonts.Contains(f)); using var pdfExport = new PDFExport { EmbeddingFonts = hasNonStandardFonts }; report.Export(pdfExport, “output.pdf”);