PDFsharp & MigraDoc Foundation
http://forum.pdfsharp.net/

Migradoc 1.5 - Cannot apply bold style in formattedText
http://forum.pdfsharp.net/viewtopic.php?f=2&t=3590
Page 1 of 1

Author:  rbe42 [ Fri May 19, 2017 12:01 pm ]
Post subject:  Migradoc 1.5 - Cannot apply bold style in formattedText

Hello,

I'm printing some formattedText with migraDoc, but the bold effet is not rendered in my document.

here an example:
I have an html string generated with CKEditor like this:
Code:
<p><em><strong><span style="font-family:Arial,Helvetica,sans-serif"><span style="font-size:9pt">Bold and italic</span></span></strong></em></p>


I parse this string to convert each html node into migradoc formattedText.

Code:
        private void FormerNoeudHtml(HtmlNode noeud, FormattedText texte)
        {
            switch (node.Name)
            {
                case "b":
                case "strong":
                    texte.Font.Bold = true;
                    break;
                case "i":
                case "em":
                    texte.Font.Italic = true;
                    break;
                case "u":
                    texte.Font.Underline = Underline.Single;
                    break;
                case "br":
                    texte.AddLineBreak();
                    break;
                case "span":
                    // span stuff
                    break;
                case "img":
                    // img stuff
                    break;
                default:
                    break;
            }

            foreach (HtmlNode enfant in node.ChildNodes)
            {
                if (enfant.Name.Substring(0, 1) == "#" && enfant.Name != "#document")
                {
                    texte.AddText(noeud.InnerText);
                }
                else
                {
                    FormerNoeudHtml(enfant, texte.AddFormattedText());
                }
            }
        }


If i have italic or underline tag it's working, but bold textFormat doesn't apply on the document.

with this example, before printing I have an object like this:
paragraph.Elements[0](formattedText).Elements[0](formattedText).Elements[0](formattedText with italic == true).Elements[0](formattedText with bold == true).Elements[0](formattedText with fontName == "Arial,Helvetica,sans-serif").Elements[0](formattedText with size == {9}).Elements[0](Text with content == "Bold and italic")

what did I miss?
Thanks.

Author:  rbe42 [ Fri May 19, 2017 1:35 pm ]
Post subject:  Re: Migradoc 1.5 - Cannot apply bold style in formattedText

Nevermind, i understood why it didn't work.
you can't have a html font name like 'Arial, Helvetica, Sans-serif', with 'Arial' only it's working

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/