forked from alchemy-fr/PHP-XPDF
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4638cd5
commit 0c7a414
Showing
1 changed file
with
76 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,86 @@ | ||
#PHP-XPDF | ||
# PHP-XPDF | ||
|
||
[![Build Status](https://secure.travis-ci.org/alchemy-fr/PHP-XPDF.png?branch=master)](http://travis-ci.org/alchemy-fr/PHP-XPDF) | ||
|
||
PHP-XPDF is an object oriented wrapper for XPDF. For the moment, only PdfTotext | ||
wrapper is available. | ||
|
||
##Documentation | ||
## Installation | ||
|
||
Find the full documentation at [Read The Docs](http://php-xpdf.readthedocs.org). | ||
It is recommended to install PHP-XPDF through [Composer](http://getcomposer.org) : | ||
|
||
##License | ||
```json | ||
{ | ||
"require": { | ||
"php-xpdf/php-xpdf": "~0.2.0" | ||
} | ||
} | ||
``` | ||
|
||
## Dependencies : | ||
|
||
In order to use PHP-XPDF, you need to install XPDF. Depending of your | ||
configuration, please follow the instructions at on the | ||
[XPDF website](http://www.foolabs.com/xpdf/download.html). | ||
|
||
|
||
## Documentation | ||
|
||
### Driver Initialization | ||
|
||
The easiest way to instantiate the driver is to call the `create method. | ||
|
||
```php | ||
$pdfToText = XPDF\PdfToText::create(); | ||
``` | ||
|
||
You can optionaly pass a configuration and a logger (any | ||
`Psr\Logger\LoggerInterface`). | ||
|
||
```php | ||
$pdfToText = XPDF\PdfToText::create(array( | ||
'pdftotext.binaries' => '/opt/local/xpdf/bin/pdftotext', | ||
'pdftotext.timeout' => 30, // timeout for the underlying process | ||
), $logger); | ||
``` | ||
|
||
### Extract text | ||
|
||
To extract text from PDF, use the `getText` method. | ||
|
||
```php | ||
$text = $pdtTotext->getText('document.pdf'); | ||
``` | ||
|
||
You can optionally extract from a page to another page. | ||
|
||
```php | ||
$text = $pdtTotext->getText('document.pdf', $from = 1, $to = 4); | ||
``` | ||
|
||
### Use with Silex | ||
|
||
A [Silex](http://silex.sensiolabs.org) service provider is available | ||
|
||
```php | ||
$app = new Silex\Application(); | ||
$app->register(new XPDF\XPDFServiceProvider()); | ||
|
||
$app['xpdf.pdftotext']->getText('document.pdf'); | ||
``` | ||
|
||
Options can be passed to customize the provider. | ||
|
||
```php | ||
$app->register(new XPDF\XPDFServiceProvider(), array( | ||
'xpdf.configuration' => array( | ||
'pdftotext.timeout' => 30, | ||
'pdftotext.binaries' => '/opt/local/xpdf/bin/pdftotext', | ||
), | ||
'xpdf.logger' => $logger, | ||
)); | ||
``` | ||
|
||
## License | ||
|
||
This project is licensed under the [MIT license](http://opensource.org/licenses/MIT). |