Siegmann epublib计算目录的页码

时间:2019-06-24 10:29:01

标签: java android epub epublib

我使用“ Siegmann epublib”库来提取android项目中epub文件的内容。我可以显示这本书的全部内容并对其进行分页;但是如何在目录和这些页面之间找到​​关联?因为目录具有树形结构,但是资源(书的内容)是没有任何深度的列表。

这是我获取全部内容的代码:

List<Resource> resources = book.getContents();
StringBuilder total = new StringBuilder();
for(int i = 0;i < resources.size();i++){
    Resource resource = resources.get(i);
    String htmlData = new String(resource.getData());
    total.append(TextTools.htmlToText(htmlData));
}

这是我获取目录的方式:

List<TOCReference> tocReferences = book.getTableOfContents().getTocReferences();
for(int i = 0;i < tocReferences.size();i++){
    // Get tree structure of table of contents
    // If has children use a nested loop to get them...
}

0 个答案:

没有答案
相关问题