Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.
Tue Nov 07, 2023 7:06 am
HeaderFooter header = section.getHeadersFooters().getHeader();
HeaderFooter footer = section.getHeadersFooters().getFooter();
Paragraph footerParagraph = footer.addParagraph();
footerParagraph.appendField("Page Number", FieldType.Field_Page);
footerParagraph.getFormat().setHorizontalAlignment(HorizontalAlignment.Center);
I have written above code to add page number in footer .How to change the fontsize and fontName of footer paragraph
-

pr20080798
-
- Posts: 159
- Joined: Wed Jan 20, 2021 1:15 pm
Tue Nov 07, 2023 8:23 am
Hi,
Thanks for your inquriy.
Please refer to the following code.
- Code: Select all
Document doc = new Document();
// Create a new style
Style style = doc.addStyle(BuiltinStyle.Footer);
style.getCharacterFormat().setFontName("Calibri");
style.getCharacterFormat().setFontSize(15);
Section section = doc.addSection();
HeadersFooters headersFooters = section.getHeadersFooters();
HeaderFooter footer = headersFooters.getFooter();
Paragraph footerParagraph = footer.addParagraph();
footerParagraph.appendField("Page Number", FieldType.Field_Page);
footerParagraph.getFormat().setHorizontalAlignment(HorizontalAlignment.Center);
// Apply the newly added style
footerParagraph.applyStyle(style.getName());
doc.saveToFile("result.docx");
If you have any other questions, just feel free to contact us.
Best regards,
Triste
E-iceblue support team
-


Triste.Dai
-
- Posts: 1000
- Joined: Tue Nov 15, 2022 3:59 am