Search code examples
pdfpdf-generationformatted-textdynamicpdf

cete.DynamicPdf formattedTextArea doesn't render html


I am trying to create a pdf with text formatting using cete.dynamicpdf and html I am using the formattedtextarea which supposedly can handle html input.

     FontFamily ff = new FontFamily("fontFamily", font);
        FormattedTextAreaStyle style = new FormattedTextAreaStyle(ff, fontSize, true);
        FormattedTextArea textArea = new FormattedTextArea(HttpUtility.HtmlDecode(text), x * mmToPoints, y * mmToPoints, w * mmToPoints, h * mmToPoints, style);

I am currently passing simple some text tags to the "text", but when the documents gets created no bold text is to be seen.


Solution

  • I needed to define some fonts for the fontfamily object to get the tags to work

        //Building font objects and FontFamily object. 
            TrueTypeFont verdanaRegularFont = new TrueTypeFont("verdana.TTF");
            TrueTypeFont verdanaBoldFont = new TrueTypeFont("verdanab.TTF");
            TrueTypeFont verdanaBoldItalicFont = new TrueTypeFont("verdanaz.TTF");
            TrueTypeFont verdanaItalicFont = new TrueTypeFont("verdanai.TTF");
            FontFamily verdanaFontFamily = new FontFamily("VerdanaFontFamily", verdanaRegularFont, verdanaBoldFont, verdanaItalicFont, verdanaBoldItalicFont); 
            FormattedTextAreaStyle style = new FormattedTextAreaStyle(verdanaFontFamily, fontSize, true);
            FormattedTextArea textArea = new FormattedTextArea(HttpUtility.HtmlDecode(text), x * mmToPoints, y * mmToPoints, w * mmToPoints, h * mmToPoints, style);