Skip to content

3.2 Font Resources

OgreTransporter edited this page Mar 2, 2020 · 1 revision

The DefineFontResources method creates all the font resources used in this example. To see all the characters available for any font, press the button “Font Families”. Select a family and view the glyphs defined for each character. To view individual glyph press view or double click.

// Define Font Resources
private void DefineFontResources()
{
    // Define font resources
    // Arguments: PdfDocument class, font family name, font style, embed flag
    // Font style (must be: Regular, Bold, Italic or Bold | Italic) All other styles are invalid.
    // Embed font. If true, the font file will be embedded in the PDF file.
    // If false, the font will not be embedded
    string FontName1 = "Arial";
    string FontName2 = "Times New Roman";

    ArialNormal = PdfFont.CreatePdfFont(Document, FontName1, FontStyle.Regular, true);
    ArialBold = PdfFont.CreatePdfFont(Document, FontName1, FontStyle.Bold, true);
    ArialItalic = PdfFont.CreatePdfFont(Document, FontName1, FontStyle.Italic, true);
    ArialBoldItalic = PdfFont.CreatePdfFont(Document, FontName1, FontStyle.Bold | FontStyle.Italic, true);
    TimesNormal = PdfFont.CreatePdfFont(Document, FontName2, FontStyle.Regular, true);
    Comic = PdfFont.CreatePdfFont(Document, "Comic Sans MS", FontStyle.Bold, true);
    return;
}
Clone this wiki locally