Skip to content

jove4015/epub-to-text

 
 

Repository files navigation

Extract text from an epub

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

License

The MIT License (MIT). Please see License File for more information.

About

Extract text from an ebook

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%