Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ag2s20150909/epublib


https://github.com/ag2s20150909/epublib

Last synced: about 2 months ago
JSON representation

Awesome Lists containing this project

README

        

# EpubLib

A Android library for reading/writing/manipulating EPUB files, with improvements based on [epublib](https://github.com/psiegman/epublib). and [epub4j](https://github.com/documentnode/epub4j)

Comparing to the original epublib and epub4j, we contains the following changes:
* Switched to Android library only work in Android.
* Removed the dependency of kxml2,not need for Android.
* Add support of EPUB 3.x.
* ~~Upgrade jzlib to last version.~~ Just use JDK for ZIP.

## 使用方法

//读取epub
EpubReader reader = new EpubReader();
InputStream in = getAssets().open(name);
//InputStream in= new FileInputStream(new File(filepath));
Book book = reader.readEpub(in);

//获取epub文件版本
String epubVersion=book.getVersion()

//获取epub文件信息
Metadata metadata = book.getMetadata();
String bookInfo = "作者:"+metadata.getAuthors()+
"\n出版社:"+metadata.getPublishers()+
"\n出版时间:" +metadata.getDates()+
"\n书名:"+metadata.getTitles()+
"\n简介:"+metadata.getDescriptions()+
"\n语言:"+metadata.getLanguage()+
"\n";

//获取线性的阅读菜单
List spineReferences = book.getTableOfContents().getAllUniqueResources();
for(Resource sp:spineReferences){
Log.d(TAG,sp.getHref()+sp.getTitle());
}

//获取层级的菜单
List tocReferences =book.getTableOfContents().getTocReferences();
for (TOCReference top:tocReferences){
Resource topres= top.getResource();
Log.d(TAG,"父目录"+topres.getHref()+topres.getTitle());
if (top.getChildren().size()>0){
for (TOCReference child:top.getChildren()){
Resource childres= child.getResource();
Log.d(TAG,"子目录"+childres.getHref()+childres.getTitle());
}
}
}

### EPUB2 and EPUB3
![epub2](img/epub2.jpg)
![epub3](img/epub3.jpg)