//循环word中的每一节
for (int j = 0; j < data.newDoc.Sections.Count; j++)
{
Section section = data.newDoc.Sections[j];
//怎样获取当前节(section )第一页和最后一页的页码?
}
// 加载文档
Document doc = new Document();
doc.loadFromFile("TestCircle.docx");
// 将文档转换为固定版式
FixedLayoutDocument fixedLayoutDocument = new FixedLayoutDocument(doc);
// 获取指定章节
Section sec = doc.getSections().get(2);
// 获取章节的第一个段落
Paragraph para_start = sec.getParagraphs().get(0);
// 获取第一个段落的页码
LayoutCollection<LayoutElement> layoutElements_start = fixedLayoutDocument.getLayoutEntitiesOfNode(para_start);
System.out.println(layoutElements_start.get(0).getPageIndex());
// 获取最后一个段落
Paragraph para_end = sec.getParagraphs().get(sec.getParagraphs().getCount()-1);
// 获取最后一个段落的页码
LayoutCollection<LayoutElement> layoutElements_end = fixedLayoutDocument.getLayoutEntitiesOfNode(para_end);
System.out.println(layoutElements_end.get(0).getPageIndex());