PHP code example of hans-thomas / epub
1. Go to this page and download the library: Download hans-thomas/epub library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
hans-thomas / epub example snippets
// Open an EPUB file
$epub = new Epubli\Epub\Epub('/path/to/your/book.epub');
// and read some of its metadata
$title = $epub->getTitle();
$authors = $epub->getAuthors();
$desc = $epub->getDescription();
// Get the EPUB’s structural elements
$toc = $epub->getToc();
$spine = $epub->getSpine();
// Iterate over the EPUB structure
foreach ($spine as $spineItem) {
// Get some text from the EPUB
$chapterText = $spineItem->getContents();
// Or find all navigation points pointing to that spine item
$navPoints = $toc->findNavPointsForFile($spineItem->getHref());
// Do something useful with the NavPoints.
// At the end, don't forget to close the spine item
$spineItem->close();
}