Surround header and surround footer

Hi Team,

Could you provide a example code (java code) where header/footer is included/excluded within the page border using surround header/footer API (like below) from Aspose.

pageSetup.setBorderSurroundsHeader(true/false);
pageSetup.setBorderSurroundsFooter(true/false);

Thanks,
Kumar

Hi Team,

I managed to find an example. Correct if it’s incorrect.

private static void headerFooter(DocumentBuilder builder) throws Exception {
    Section currentSection = builder.getCurrentSection();
    PageSetup pageSetup = currentSection.getPageSetup();

    pageSetup.setDifferentFirstPageHeaderFooter(true);

    pageSetup.setBorderDistanceFrom(PageBorderDistanceFrom.TEXT);

    pageSetup.setBorderSurroundsHeader(true);
    pageSetup.setBorderSurroundsFooter(false);

    pageSetup.getBorders().setLineStyle(1);

    // — Create header for the first page. —
    pageSetup.setHeaderDistance(20);
    builder.moveToHeaderFooter(HeaderFooterType.HEADER_FIRST);
    builder.getParagraphFormat().setAlignment(ParagraphAlignment.CENTER);

    builder.write("Aspose.Words Header/Footer Creation Primer - Title Page.");

    builder.moveToDocumentStart();
    builder.write("Normal text in the body");
}

Thanks,
Kumar

Hi Kumar,

Thanks for your inquiry. It is nice to hear from you that you have solved your query. Yes, you are using setBorderSurroundsHeader and setBorderDistanceFrom methods correctly. Please read following documentation links for your kind reference.
https://reference.aspose.com/words/java/com.aspose.words/PageSetup
https://reference.aspose.com/words/java/com.aspose.words/pagesetup#BorderDistanceFrom

Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.