//去除目录文字蓝色样式以及文字下方蓝色下划线for(FieldStart field: (Iterable<FieldStart>)doc.getChildNodes(NodeType.FIELD_START, true)){if (field.getFieldType() == FieldType.FIELD_HYPERLINK){FieldHyperlink hyperlink = (FieldHyperlink)field.getField();//判断是否是目录if (hyperlink.getSubAddress() != null && hyperlink.getSubAddress().startsWith("_Toc")) {//获取目录每行段落对象Paragraph tocItem = (Paragraph)field.getAncestor(NodeType.PARAGRAPH);if (tocItem != null) {//设置每行目录样式for (Run run : tocItem.getRuns()) {run.getFont().setColor(Color.BLACK);run.getFont().setBold(false);run.getFont().setUnderline(Underline.NONE);}}}}}
转载于:https://www.cnblogs.com/haohj/p/10340518.html