PHP code example of liz / php-xpdf

1. Go to this page and download the library: Download liz/php-xpdf 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/ */

    

liz / php-xpdf example snippets


$pdfToText = XPDF\PdfToText::create();

$pdfToText = XPDF\PdfToText::create(array(
    'pdftotext.binaries' => '/opt/local/xpdf/bin/pdftotext',
    'pdftotext.timeout' => 30, // timeout for the underlying process
), $logger);

$text = $pdtTotext->getText('document.pdf');

$text = $pdtTotext->getText('document.pdf', $from = 1, $to = 4);

$pdtTotext->setpageQuantity(2);
$pdtTotext->getText('document.pdf'); // extracts page 1 and 2

$app = new Silex\Application();
$app->register(new XPDF\XPDFServiceProvider());

$app['xpdf.pdftotext']->getText('document.pdf');

$app->register(new XPDF\XPDFServiceProvider(), array(
    'xpdf.configuration' => array(
        'pdftotext.timeout'  => 30,
        'pdftotext.binaries' => '/opt/local/xpdf/bin/pdftotext',
    ),
    'xpdf.logger' => $logger,
));
json
{
    "hp-xpdf/php-xpdf": "~0.2.0"
    }
}