سؤال

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.

هل كانت مفيدة؟

المحلول

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);
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top