请问如何解析出文档的层次结构呢?
我这边解析docx:
Document doc = new Document(path+filename+"."+suffix);
for(Section section : doc.getSections().toArray()){
ParagraphCollection collection = section.getBody().getParagraphs();
for(int i =0; i<collection.toArray().length; i++){
System.out.println(collection.get(i).getListLabel().getLabelString()+" "+collection.get(i).getText());
}
}
解析pdf:
Document doc = new Document(path+filename+"."+suffix);
TextFragmentAbsorber textFragmentAbsorber = new TextFragmentAbsorber();
doc.getPages().accept(textFragmentAbsorber);
String content1 = textFragmentAbsorber.getText();
System.out.println(content1);
解析出来的内容平铺的,并无层次结构(如:1.1.1章节属于1.1章节,1.1章节属于1章节)。
请问是否有线程方法可以解析出层次结构呢?还是说需要一些个性化的开发