user3424829
user3424829

Reputation: 141

How to make Some text bold in a paragraph while generating from novacode docx library in c#

I want to make some text bold like that.. • Basic – There are no Cybersecurity

Upvotes: 0

Views: 1872

Answers (1)

DCOPTimDowd
DCOPTimDowd

Reputation: 231

One way of doing this is to insert the bolded text separately into the same paragraph.

// Create the proper formats first
Formatting bold = new Formatting();
bold.Bold = true;

Formatting notBold = new Formatting();

// Create the file
DocX doc = DocX.Create("test.docx");

// Insert the text you want with the proper formatting for each section
Paragraph para = doc.InsertParagraph();
para.InsertText("not bold text ", false, notBold);
para.InsertText("bold text ", false, bold);
para.InsertText("not bold text", false, notBold);

doc.Save();

This will output:

not bold text bold text not bold text

Upvotes: 0

Related Questions