Notice
Recent Posts
Recent Comments
반응형
오늘도 공부
epub reader source for android or java 본문
반응형
link from : http://www.siegmann.nl/epublib/android
Android
Epublib-core runs on Android.
Reading, writing and manipulating epub files is fully supported.
Requirements
- Slf4j-android.
You can download this at http://www.slf4j.org/android/
Getting started
- Download epublib-core-latest.jar from https://github.com/downloads/psiegman/epublib/epublib-core-latest.jar
- Download slf4j-android
- Add both to your android project
Example code
This Logs info of 'assets/books/testbook.epub'.
importjava.io.IOException;importjava.io.InputStream;importjava.util.List;importnl.siegmann.epublib.domain.Book;importnl.siegmann.epublib.domain.TOCReference;importnl.siegmann.epublib.epub.EpubReader;importandroid.app.Activity;importandroid.content.res.AssetManager;importandroid.graphics.Bitmap;importandroid.graphics.BitmapFactory;importandroid.os.Bundle;importandroid.util.Log;/*** Log the info of 'assets/books/testbook.epub'.** @author paul.siegmann**/publicclassLogTestBookInfoextendsActivity {/** Called when the activity is first created. */@OverridepublicvoidonCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.main);AssetManager assetManager = getAssets();try{// find InputStream for bookInputStream epubInputStream = assetManager.open("books/testbook.epub");// Load Book from inputStreamBook book = (newEpubReader()).readEpub(epubInputStream);// Log the book's authorsLog.i("epublib","author(s): "+ book.getMetadata().getAuthors());// Log the book's titleLog.i("epublib","title: "+ book.getTitle());// Log the book's coverimage propertyBitmap coverImage = BitmapFactory.decodeStream(book.getCoverImage().getInputStream());Log.i("epublib","Coverimage is "+ coverImage.getWidth() +" by "+ coverImage.getHeight() +" pixels");// Log the tale of contentslogTableOfContents(book.getTableOfContents().getTocReferences(),0);}catch(IOException e) {Log.e("epublib", e.getMessage());}}/*** Recursively Log the Table of Contents** @param tocReferences* @param depth*/privatevoidlogTableOfContents(List<TOCReference> tocReferences,intdepth) {if(tocReferences ==null) {return;}for(TOCReference tocReference : tocReferences) {StringBuilder tocString =newStringBuilder();for(inti =0; i < depth; i++) {tocString.append("\t");}tocString.append(tocReference.getTitle());Log.i("epublib", tocString.toString());logTableOfContents(tocReference.getChildren(), depth +1);}}}
반응형
'Android > Tip&Tech' 카테고리의 다른 글
| [펌][Android] 많은 버튼의 클릭이벤트 처리 : button onClick() : OnClickListener (1) | 2011.07.23 |
|---|---|
| 안드로이드 주소록에서 보여지는 퀵액션 같은 걸 붙여보자 (1) | 2011.07.21 |
| listview 관련 팁 (0) | 2011.07.18 |
| [펌]동적으로 listview 끝에 스크롤시 로딩시키기 (0) | 2011.07.18 |
| android HttpClient 재사용(reuse) 관한 팁 (0) | 2011.07.13 |
