MigraDoc - Bold certain text in a paragraph

contactmatt picture contactmatt · Sep 13, 2012 · Viewed 9.1k times · Source

In MigraDoc, if I have a paragraph, how can I only bold some text in the paragraph, not the entire paragraph.

Edit: Below is the typical code I would use to add a bolded paragraph.

var paragraph = section.AddParagraph("This text");
paragraph.Format.Font.Bold = true;

I can't just add separate paragraphs splitting the text, because MigraDoc puts space between the paragraphs.

Answer

Victor picture Victor · Sep 14, 2012

Try the following lines:

var paragraph = section.AddParagraph("This text"); 

paragraph.AddFormattedText("Text in Bold Style", TextFormat.Bold);