PDFsharp & MigraDoc Foundation

PDFsharp - A .NET library for processing PDF & MigraDoc Foundation - Creating documents on the fly
It is currently Thu Mar 28, 2024 11:07 am

All times are UTC


Forum rules


Please read this before posting on this forum: Forum Rules



Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Fri May 19, 2017 12:01 pm 
Offline

Joined: Tue Jan 12, 2016 12:17 pm
Posts: 9
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.


Top
 Profile  
Reply with quote  
PostPosted: Fri May 19, 2017 1:35 pm 
Offline

Joined: Tue Jan 12, 2016 12:17 pm
Posts: 9
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


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 127 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Privacy Policy, Data Protection Declaration, Impressum
Powered by phpBB® Forum Software © phpBB Group