java - Spacing and Margin settings in MS Word document using Apache POI docx - Stack Overflow

Got the answer..

    documentTitle.setAlignment(ParagraphAlignment.CENTER);
    // This does the trick
    documentTitle.setSpacingBefore(100);

It left me 100pt space between each line of the text

If you want to add custom margins to your document. use this code.

    CTSectPr sectPr = document.getDocument().getBody().addNewSectPr();
    CTPageMar pageMar = sectPr.addNewPgMar();
    pageMar.setLeft(BigInteger.valueOf(720L));
    pageMar.setTop(BigInteger.valueOf(1440L));
    pageMar.setRight(BigInteger.valueOf(720L));
    pageMar.setBottom(BigInteger.valueOf(1440L));

原网址: 访问
创建于: 2023-05-06 14:32:47
目录: default
标签: 无

请先后发表评论
  • 最新评论
  • 总共0条评论