docx4j - Why is the text truncated of spaces?

前端 未结 1 1728
故里飘歌
故里飘歌 2021-02-10 17:59

Here is the code:

    P para = factory.createP();
    R run = factory.createR();
    Text text = factory.createText();

    text.setValue( \"              abc            


        
相关标签:
1条回答
  • 2021-02-10 18:36

    You need to tell docx4j to explicitly preserve whitespace in your Text instances (the underlying format is XML of course, which tends not to pay much heed to whitespace). Something like this:

    text.setValue("              abc             ");
    text.setSpace("preserve");
    ...
    
    0 讨论(0)
提交回复
热议问题