获取Docment, 将文档中的所有段落格式化
段落后间距:0磅
行间距:最小值,0
你好,暂时没有看到解决方案,之前在网上看一些网友说没有该解决方案
似乎您想将一个文档附加到另一个文档中并设置段落格式。 请使用下面的代码示例获取所需的输出。
Document doc1 = new Document(MyDir +"test1.docx");
Document doc2 = new Document(MyDir +"test2.docx");
for (Paragraph paragraph : (Iterable<Paragraph>) doc1.getChildNodes(NodeType.PARAGRAPH, true)){
paragraph.getParagraphFormat().setSpaceBefore(0);
paragraph.getParagraphFormat().setSpaceAfter(0);
paragraph.getParagraphFormat().setLineSpacing(0);
paragraph.getParagraphFormat().setLineSpacingRule(LineSpacingRule.AT_LEAST);
}
doc2.getFirstSection().getPageSetup().setSectionStart(SectionStart.CONTINUOUS);
doc1.appendDocument(doc2, ImportFormatMode.KEEP_SOURCE_FORMATTING);
doc1.save(MyDir + "result.docx");
非常感谢,我还想在问一个问题,怎么将文档中的回车换行删除。例如,将一个文档附加到另一个文档,但是另一个文档中含有回车换行,怎么将其删除
Thank you very much for your prompt reply. If you want to come to China to play, you are willing to be your tour guide. Haha
你好,问题已经解决了,非常感谢您,谢谢。