Font size not changing in footer using Aspose Words for Java API

@alexey.noskov
Was using this code snippet to change the size of font etc of the footer text:

com.aspose.words.Document doc = new Document(fileDir + fname);
com.aspose.words.DocumentBuilder builder = new com.aspose.words.DocumentBuilder(doc);
builder.getFont().setName("Arial");
builder.getFont().setBold(false);
builder.getFont().setSize(5);
builder.getFont().setName("Arial");
builder.getFont().setBold(false);
builder.getFont().setSize(10);

but the footer text size etc doesnt get changed when displayed.it shows as follows:

@sabkan The provided code does not change header font. The code simply change the font used by builder while inserting content. Please see the following code:

builder.getFont().setName("Arial");
builder.getFont().setBold(false);
builder.getFont().setSize(10);
builder.write("This is not bold Arial text of 10pt size");

Please see our documentation to learn more:
https://docs.aspose.com/words/java/working-with-fonts/

Was trying to use the code snippet from this link:

https://docs.aspose.com/words/java/working-with-headers-and-footers/#set-font-and-paragraph-properties-for-header-or-footer-text

So why is it not changing the text size etc or am I missing something.

Thanks

@sabkan The code works fine. Here is the produced output:
out.docx (7.6 KB)

Font of the footer text is bold Arial 14, just as expected.

ok ,got the issue. i had to set the size etc after this code.
builder.moveToHeaderFooter(com.aspose.words.HeaderFooterType.FOOTER_PRIMARY);

Now it is working as expected.

Thanks

1 Like