Zeba Books EPUB Viewer
High-performance EPUB renderer with annotation support, CC metadata extraction, and customizable themes for Flutter.
Features
- Load EPUBs from assets, files, or bytes.
- Chapter pagination with automatic page splitting.
- Annotations & bookmarks per chapter and page.
- Customizable themes: classic, dark, and light.
- Supports NCX TOC for navigation.
- CC metadata extraction for Creative Commons licensing.
Installation
Add the dependency in your pubspec.yaml:
dependencies:
zeba_books_epub_viewer:
git:
url: https://github.com/yourusername/zeba_books_epub_viewer.git
ref: main
Run:
flutter pub get
Usage
Basic Example
import 'package:flutter/material.dart';
import 'package:zeba_books_epub_viewer/zeba_books_epub_viewer.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
home: const EpubExample(),
);
}
}
class EpubExample extends StatefulWidget {
const EpubExample({super.key});
@override
State<EpubExample> createState() => _EpubExampleState();
}
class _EpubExampleState extends State<EpubExample> {
final parser = EpubParser();
@override
void initState() {
super.initState();
parser.loadEpubAsset('test_assets/sample.epub');
}
@override
Widget build(BuildContext context) {
return EpubView(
parser: parser,
bookId: 'sample_book',
fontSize: 18,
theme: EpubTheme.classic,
);
}
}
Loading EPUB
From Asset
await parser.loadEpubAsset('assets/sample.epub');
From File
await parser.loadEpubFile('/path/to/book.epub');
From Bytes
await parser.loadEpubBytes(epubBytes);
Annotations
await AnnotationDB.addAnnotation(
Annotation(
bookId: 'sample_book',
chapter: 0,
page: 0,
note: 'My note',
),
);
Themes
EpubTheme.classic(default)EpubTheme.darkEpubTheme.light
Example:
EpubView(
parser: parser,
bookId: 'sample_book',
theme: EpubTheme.dark,
);
Pagination
The viewer automatically paginates chapters based on:
fontSizelineHeight- Device screen width & height
Use _nextChapter() and _prevChapter() to navigate manually.
License
This package is available under the MIT License.
Contributing
- Fork the repository.
- Make changes in a new branch.
- Run
flutter testto ensure all tests pass. - Open a pull request.