java - Siegmann 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...
}
解决方案
推荐阅读
- grails - grails - 找不到命令安装模板
- mysql - 如何在mysql中减去2个值集来填充数据
- spring-boot - 如何从集群中正在运行的 Spring Boot 应用程序中动态创建 Kubernetes 资源
- quartz-scheduler - 无法在 javax 电子邮件中创建 Mimemesage
- jquery - 在 jQuery 中同时使用淡入淡出和淡入淡出作为 CSS 中的过渡
- azure-devops - Azure DevOps 管道代理在 CNTLM 代理后面不起作用?
- xcode - 在 Xcode 日志中,'[number1:number2]' 是什么意思?
- python-3.x - PermissionError: [Errno13] 权限被拒绝
- automation - 如何在 JMeter 中添加响应和请求正文到邮件?
- reactjs - React 甚至设置了静态 defaultProps,但是报错为什么?