Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files from any .NET platform (C#, VB.NET, ASP.NET, .NET Core) and Java applications (J2SE and J2EE) with fast and high quality performance.

Fri Mar 18, 2011 2:22 pm

I wish to create a new paragraph of "DefaultParagraphFont", and within the paragraph make some of the text bold, how do I write this ?

jdupee@edocuments.co.uk
 
Posts: 3
Joined: Wed Mar 09, 2011 2:56 pm

Mon Mar 21, 2011 10:09 am

Hi friend,
Thanks for your inquiry.
Please try:
Code: Select all
Document document = new Document();
Section section = document.AddSection();
Paragraph paragraph = section.AddParagraph();
paragraph.AppendText("Normal ");

TextRange text = paragraph.AppendText("Bold");
text.CharacterFormat.Bold = true;

paragraph.AppendText(" ");

text = paragraph.AppendText("Italic");
text.CharacterFormat.Italic = true;

paragraph.AppendText(" ");

text = paragraph.AppendText("ItalicBold");
text.CharacterFormat.Italic = true;
text.CharacterFormat.Bold = true;

paragraph.AppendText(" Normal ");

document.SaveToFile("test.doc");
document.Close();
Harry
Technical Support / Developer,
e-iceblue Support Team
User avatar

harry.support
 
Posts: 180
Joined: Mon Nov 08, 2010 3:11 pm

Return to Spire.Doc