ActiveReports 11
Custom Font Factory (Pro Edition)
ActiveReports 11 > ActiveReports User Guide > Concepts > Exporting > Custom Font Factory (Pro Edition)

When you use the PDF export filter in a Medium trust environment, ActiveReports does not have access to the System Fonts folder due to security restrictions. So if your reports use special glyphs or non-ASCII characters that are only found in certain fonts, the PDF output may be incorrect on some machines.

The ActiveReports custom font factory allows you to embed any fonts you need in PDF in the Medium trust environment. To deploy the necessary fonts with your Medium trust solution, you must add the used font files in the specific folder and set up your web.config file.

ActiveReports looks for the custom fonts in the order as follows:

  1. A font specified in the control.
  2. A mapped specified font in the Substitute setting.
  3. A font specified in the the AddFontLink setting (Pro Edition only).
  4. A font specified in the SetFallbackFont setting (Pro Edition only).

Notice that you need to copy the required font files (.ttc, .ttf) manually into the font folder you are accessing.

Custom Font Factory in Windows Azure

For your Azure project, you need to set the properties for all fonts in the project Fonts folder as follows:

  1. Set Copy to Output Directory to Copy always.
  2. Set BuildAction to Content.

To add a font factory section group

XML code. Paste INSIDE the configSections tags of the web.config file.
Copy Code
<sectionGroup name="ActiveReports.PdfExport">    <section name="FontFactory"           type="GrapeCity.ActiveReports.Web.FontFactorySectionHandler,           GrapeCity.ActiveReports.Web.v7,           Version=7.99.10395.0, Culture=neutral, PublicKeyToken=cc4967777c49a3ff"           requirePermission="false" /></sectionGroup>

To create a font factory

Required fonts or the folder containing the required fonts are set in the font factory. Paste code like the following after the configSections tag, but before the appSettings tag.

Note: Please make the required changes for the font that you wish to use. In case of the following sample code, create a Font folder and copy the required font files (arial.ttf, tahoma.ttf, msgothic.ttc, simsun.ttc, gulim.ttc, mingliu.ttc, micross.ttf).
XML code. Paste between configSections and appSettings tags of the web.config file.
Copy Code
<ActiveReports.PdfExport>
    <FontFactory Mode="File">
        <AddFolder VirtualPath="~/Fonts" Recurse="true"/>
        <Substitute Font="Helv" To="Helvetica"/>
        <SetFallbackFont Font="Arial"/>
        <!-- font link nodes -->
        <AddFontLink Font="Arial" List="SimSun,gulim,PMingLiU"/>
        <AddFontLink Font="Tahoma" List="MS UI Gothic,SimSun,gulim,PMingLiU"/>
        <AddFontLink Font="MS UI Gothic" List="SimSun,gulim,PMingLiU,Microsoft Sans Serif" IsDefault="true"/>
    </FontFactory>
</ActiveReports.PdfExport>
Note: For the Azure worker role project, use an absolute path instead of a virtual path in the code above: <AddFolder Path="~/Fonts" Recurse="true"/>.
Copy Code

Configuration settings

FontFactory

Description: This is the main font factory node to which you can add fonts.

Attributes

Element Description
Mode

Setting the Mode attribute to File allows to use a file based factory, or remove the attribute for a Windows GDI factory.

Child Elements

None.

Parent Elements

Element Description
ActiveReports.PdfExport

The assembly that contains the PdfExport namespace (PDF export, document options, and security classes).

Example

<FontFactory Mode="File">

AddFolder

Description: Adds all TrueType fonts (.ttc, .ttf) from the specified folder.

Attributes

Element Description
Path

Specifies the absolute path to the folder.

VirtualPath Specifies the relative path to the folder.
Recurse When set to True, it can read the subfolder. When set to False, it cannot read the subfolder.

Child Elements

None.

Parent Elements

Element Description
FontFactory

This is the main font factory node to which you can add fonts.

Example

<AddFolder VirtualPath="~/Fonts" Recurse="true"/>

Substitute

Description: Maps an alternate name of fonts to their official names.

Attributes

Element Description
Font

Specifies the abbreviated font name (e.g. "Helv").

To Specifies the official font name (e.g. "Helvetica").

Child Elements

None.

Parent Elements

Element Description
FontFactory

This is the main font factory node to which you can add fonts.

Example

 <Substitute Font="Helv" To="Helvetica"/>

SetFallbackFont (Professional Edition only)

Description: In the Professional Edition, sets the font to use if a) the specified font is not installed, b) the Substitute font is not specified or not installed, or c) the font links are not set or the needed glyphs are not found in the AddFontLink setting.

Attributes

Element Description
Font

Specifies the font name.

Child Elements

None.

Parent Elements

Element Description
FontFactory

This is the main font factory node to which you can add fonts.

Example

 <SetFallbackFont Font="Arial"/> 

AddFontLink (Professional Edition only)

Description: In the Professional Edition, there is the extra support for CJK glyphs. You can add font links that allow the PdfExport to look up any glyphs missing from the specified font in the list of other fonts to check.

Attributes

Element Description
Font

Specifies the font used in the reports.

List Specifies the comma-separated list of fonts to be used in case the glyph is not found.
Caution: The character style of the link won't be outputted in case the alternate font file does not exist in the specified folder of the AddFolder setting.
IsDefault When set to True, indicates to use the specified list for any fonts that do not have their own font links.

Child Elements

None.

Parent Elements

Element Description
FontFactory

This is the main font factory node to which you can add fonts.

Example

 <AddFontLink Font="Tahoma" List="MS UI Gothic,SimSun,gulim,PMingLiU"/>
See Also