We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

如何从目录中获取标题与页码?

在word的目录中,如何获取各个标题及其对应的页码?

你好!

我关注到你在帖子中(如何从目录中获取标题与页码?
try {
Document doc = new Document(abs_wordpath);
word_max_page = doc.getBuiltInDocumentProperties().getPages();

final String PARA_STYLE = “TOC 1”;
ArrayList paragraphs = paragraphsByStyleName(doc, PARA_STYLE);
for (Paragraph paragraph : paragraphs){
String cat_txt = paragraph.toString(SaveFormat.TEXT);
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

这段代码工作的很好,达到预期。

好的,感谢使用Aspose产品!

后续有使用疑问,随时联系我们!