This package provides a class to extract text from an epub.
\jove4015\epub2txt\Epub::getText('book.epub'); //returns the text from the epub
Behind the scenes this package leverages epub2txt. You can verify if the binary installed on your system by issueing this command:
which epub2txt
If it is installed it will return the path to the binary.
To install the binary you can follow the instructions here: (http://kevinboone.net/README_epub2txt.html)
You can install the package via composer:
$ composer require jove4015/epub-to-text
Extracting text from an epub is easy.
$text = (new Epub())
->setepub('book.epub')
->text();
Or easier:
\jove4015\EpubToText\Epub::getText('book.epub')
By default the package will assume that the epub2txt
is located at /usr/bin/epub2txt
.
If you're using the a different location pass the path to the binary in constructor
$text = (new Epub('/custom/path/to/epub2txt'))
->setepub('book.epub')
->text();
or as the second parameter to the getText
-function:
\jove4015\EpubToText\Epub::getText('book.epub', '/custom/path/to/epub2txt')
$ composer test
- Freek Van der Herten - Wrote the original pdf-to-text package on which this is based
- Kevin Boone - Wrote the epub2txt CLI utility
The MIT License (MIT). Please see License File for more information.