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

Free Support Forum - aspose.com

Changing the font in the new documents created from existing templates

I am working with generating new word documents from existing templates. I have created few bookmarks in the templates and replace them with user values using aspose.words api. Am good with that. In addition, I like to change the font of the whole document. I did not achieve this using getFont().setName(). It works fine only for news lines created in the document but not for the lines rendered from templates. But, i can able to achieve the setItalic and setAllCaps working fine for the whole document. Please help to change the font of new document.


Thanks for your request. The best way to change font name or font size in the whole document, I think, is using DocumentVisitor. Here is simple example:

String fontName = "Arial";

Document doc = new Document("C:\\Temp\\in.doc");

// Create font changer

FontChanger changer = new FontChanger(fontName);

// Change font of the entire document



FontChanger class you can find here:

Best regards,

Thanks for your reply. I don’t see the FontChanger class in this page,


Could you please confirm me the page.

Hi there,

Thanks for your inquiry.

You can find the class suggested by Alexey in that thread in the post attachment here: https://forum.aspose.com/t/72624



I see the Fontchanger class is written in C#. Could you please provide me a FontChanger written in java. I need the code to run in Linux. I tried on my own converting them to java methods. But it does not work out for me.



Thanks for your request. Sure, please see the attachment.

Best regards,