in the test.docx,
test.docx (250.2 KB)
there are footnotes that inserted by some citation management softwares. and when I use code like :
Document document = new Document("src/main/test/com/test/test.docx");
NodeCollection<Footnote> childNodes = document.getChildNodes(NodeType.FOOTNOTE, true);
for (Footnote footnote : childNodes)
{
Font font = footnote.getFont();
font.setSuperscript(true);
for (Paragraph paragraph : footnote.getParagraphs())
{
if (paragraph.hasChildNodes())
{
String text = paragraph.getText().trim();
// 如果遇到网页地址类型,设置为“左对齐”
if (text.replaceAll("\\s+", "").contains("http") ||
text.replaceAll("\\s+", "").contains("www"))
{
paragraph.getParagraphFormat().setAlignment(ParagraphAlignment.LEFT);
}
NodeCollection<Node> paragraphChildNodes = paragraph.getChildNodes(NodeType.ANY, true);
paragraph.getRuns().clear();
// 脚注内容和编号之间空一个英文字符
Run space = new Run(document, " ");
space.getFont().setName("宋体");
Run run = new Run(document, text.trim());
paragraph.getRuns().add(space);
paragraph.getRuns().add(run);
paragraph.getParagraphFormat().setKeepTogether(true);
}
}
}
document.save("src/main/test/result.docx");
and the result turns to
so, how can i deal with these ? I just want to show the original content.