jove4015 / epub-to-text
Extract text from a epub - based on spatie/pdf-to-text
Requires
- php: ^7.0
- symfony/process: ^3.0
Requires (Dev)
- phpunit/phpunit: ^6.4
This package is not auto-updated.
Last update: 2024-05-12 02:30:15 UTC
README
This package provides a class to extract text from an epub.
\jove4015\epub2txt\Epub::getText('book.epub'); //returns the text from the epub
Requirements
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)
Installation
You can install the package via composer:
$ composer require jove4015/epub-to-text
Usage
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')
Testing
$ composer test
Credits
- Freek Van der Herten - Wrote the original pdf-to-text package on which this is based
- Kevin Boone - Wrote the epub2txt CLI utility
License
The MIT License (MIT). Please see License File for more information.