How to change the font of text in whole document using .NET

Need solution for following:

* Open existing word document having text with different fonts
* Change the whole document font to "Arial"

What I am actually doing:
* Open an existing word document, having text with some font
* Other documents are insert/appended to it having different fonts
* Data is also merged in these documents
*
Need help here! While saving the final document, I need all the text to have font as “Arial”.

Details of Aspose Version
Manifest-Version: 1.0
Specification-Title: Aspose.Words for Java
Specification-Version: 10.7.0.0
Specification-Vendor: Aspose Pty Ltd
Implementation-Title: Aspose.Words for Java
Implementation-Version: 10.7.0.0
Implementation-Vendor: Aspose Pty Ltd
Release-Date: 2011.11.30

Hi,

Thanks for your query. Please use the following code snippet to change the font name to “Arial” in whole document.

Document doc = new Document("D:\\Test.docx");

// Retrieve all Runs in the document.

Node[] runs = doc.getChildNodes(NodeType.RUN, true).toArray();

for (int j = 0; j < runs.length; j++)

{

Run run = (Run)runs[j];

run.getFont().setName("Arial");

run.getFont().setSize(12.0);

}

doc.save("D:\\Out.docx");

The solution works just fine, thanks :slight_smile: