Free Support Forum - aspose.com

I think by Aspose.Words to modify the existing Word document format a paragraph- can you give an example

I think by Aspose.Words to modify the existing Word document format a paragraph, can you give an example.I have the code, but test results have not changed successfully.

foreach (Aspose.Words.Paragraph p in doca.Sections[0].Body.Paragraphs)
{
p.ParagraphFormat.Style.Font.Size = 18;
p.ParagraphFormat.Style.Font.Italic = true;
}

Hi Ponnamma,

Thanks for your inquiry and sorry for the delayed response. Please use the following code snippet for your requirements.

<span lang=“EN-GB” style=“font-family:“Courier New”;color:#2B91AF;mso-ansi-language:EN-GB;
mso-no-proof:yes”>Document<span lang=“EN-GB” style=“font-family:“Courier New”;
mso-ansi-language:EN-GB;mso-no-proof:yes”> doc = new
Document(MyDir + “in.docx”);<o:p></o:p>

foreach (Paragraph para in doc.GetChildNodes(NodeType.Paragraph, true))

{

NodeCollection runs = para.GetChildNodes(NodeType.Run, true);

foreach (Run run in runs)

{

//Change the font setting

run.Font.Bold = true;

run.Font.Size = 10;

run.Font.Name = "Arial";

}

}

You can also use DocumentBuilder to format the document's text. Please read following documentation links for your kind reference.

http://www.aspose.com/docs/display/wordsnet/DocumentBuilder+Overview
http://www.aspose.com/docs/display/wordsnet/Inserting+Document+Elements
http://www.aspose.com/docs/display/wordsnet/Specifying+Formatting
http://www.aspose.com/docs/display/wordsnet/Moving+the+Cursor
http://www.aspose.com/docs/display/wordsnet/Paragraph+Class
http://www.aspose.com/docs/display/wordsnet/Run+Class

Please let us know if you have any more queries.