We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Find H1 h2 h3 h4 h5 and change format

Hi,


I have a req that i needed to find the headers inside my doc… and change the font of it to arial 16… i can see that when i add a text using html it automatically add the font as time new roman.


THanks
Joebet

also i had tried adding an html attribute as

test h1


it didnt work…

may i know how to add or contorl font size in aspose… or just find all headings and control there fonts.

Hi Joebet,


Thanks for your inquiry. You can try using the following code:

Document doc = new Document(MyDir + @“input.docx”);

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

{

if (para.ParagraphFormat.StyleIdentifier == StyleIdentifier.Heading1)

{

foreach (Run run in para.Runs)

{

run.Font.Size = 8;

}

}

}

doc.Save(MyDir + @"16.1.0.docx");


Hope, this helps.

Best regards,