Spacing and Margin settings in MS Word document using Apache POI docx

前端 未结 1 1903
太阳男子
太阳男子 2021-01-06 23:49

I have two paragraphs and i want 100 pt space before each line. Is there a way we can do in Apache POI?

Here is the code snippet



        
相关标签:
1条回答
  • 2021-01-06 23:56

    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));
    
    0 讨论(0)
提交回复
热议问题