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

Free Support Forum - aspose.com

Manipulate Header Height

Hi, is it possible to modify the height of a header. Basically, I want to make it smaller than the default one. Specifically, I want a header of 13pts height. I use the following code snippet to initialize the header, but i haven’t found any API to set the height.

Paragraph headerParag = new Paragraph(docAspose);
ParagraphFormat pf = headerParag.getParagraphFormat();
pf.getStyle().getFont().setName(“Times New Roman”);

HeaderFooter header = new HeaderFooter(docAspose,


Hi Giorgos,

Thanks for your inquiry.

I think, in your case you can just decrease header distance (distance between top of page and header). In this case header will be moved up and there will be small gap between header and body. You can achieve this by using the following code:

Document doc = new Document(“c:\temp\x.docx”);

for (Section section : doc.getSections()){




I hope, this helps.

Best regards,

Thanks very much for your reply. I have thought this work around but I would like to make the height of the header the same as the original document I want to construct. That means that I have to decrease the height of the footer. Is this possible?

Hi Giorgos,

Thanks for your inquiry. Sure, as per your needs, you can try set different combinations of values to the FooterDistance, HeaderDistance, TopMmargin, BottomMargin attributes of the PageSetup class. You can also use PageSetup.ClearFormatting method to reset page set-up to default paper size, margins and orientation.

Best regards,