sample code for adding additional facenames to a formattedtext area

Skip Navigation LinksHome  /  Support  /  Forums  /  DynamicPDF CoreSuite for .NET (v11)  /  Re: sample code for adding additional facenames to a formattedtext area

DynamicPDF CoreSuite for .NET (v11) Forum

I am working to include multiple font faces in the same formatted text area. I have times, helvetica and a truetype windings font that all need to print in the same text area. Do you have a sample of how to register the other face names for the text area. Our solution is having issues (losing the windings font after it is called for in the formatted text area). we use similar structure when printing a left justified text line, but we break it down to just print a single font string, then the next string to the right with the different font. I think I saw in your documentation you could predefine multiple faces including truetype faces before the formatted text area is called. I just need to know what that would look like. Some sample code would really help clear this up for me. thanks Doug
Posted by a ceTe Software moderator

Yes, you can add more than one font face to a FormattedTextArea. Here is a code sample:

            Document doc = new Document();
            Page page = new Page(PageSize.Letter);

            Font fontHelvetica = Font.Helvetica;
            FontFamily helveticaFamily = new FontFamily("HeveticaFont", fontHelvetica);

            OpenTypeFont fontTimes = new OpenTypeFont(@"times.ttf");
            FontFamily timesFamily = new FontFamily("TimesFont", fontTimes);

            OpenTypeFont fontWindings = new OpenTypeFont(@"WINGDNG2.TTF");
            FontFamily wingDingsFamily = new FontFamily("WingdingsFont", fontWindings);

            string formattedText = "<p><font face='TimesFont'> Times font face, </font><font " +
            "<font face='HeveticaFont'>Helvetica font face, </font><font face='WingdingsFont'> WingDingss font face, </font></p>";

            FormattedTextAreaStyle ftaStyle=new FormattedTextAreaStyle(FontFamily.Courier,12,true);
            FormattedTextArea area = new FormattedTextArea(formattedText, 0, 0, 512, 400, ftaStyle);


You can also achieve something similar using an HtmlArea. With that, you can specify the font in the HTML source. For more information, please refer to the documentation on HtmlArea here.

ceTe Software Support Team
I will check that out. Thank you for the clear reply..

All times are US Eastern Standard time. The time now is 12:10 PM.