PHP code example of escarter / poppler-wrapper-php

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

    

escarter / poppler-wrapper-php example snippets


use Escarter\PopplerPhp\PdfToText;
use Escarter\PopplerPhp\getOutput;

echo PdfToText::getText('document.pdf','/opt/homebrew/bin/pdftotext'); //returns the text from the pdf
echo PdfSeparate::getOutput('document.pdf','/opt/homebrew/bin/pdfseparate','destination_path/page_%d.pdf'); //returns null

$text = (new PdfToText())
    ->setPdf('document.pdf')
    ->text();

echo PdfToText::getText('document.pdf');

$text = (new PdfToText('/custom/path/to/pdftotext'))
    ->setPdf('document.pdf')
    ->text();

echo PdfToText::getText('document.pdf', '/custom/path/to/pdftotext');

$text = (new PdfToText())
    ->setPdf('table.pdf')
    ->setOptions(['layout', 'r 96'])
    ->text()
;

echo PdfToText::getText('document.pdf', null, ['layout', 'opw myP1$$Word']);

 $text = (new PdfToText())
     ->setPdf('table.pdf')
     ->setOptions(['layout', 'r 96'])
     ->addOptions(['f 1'])
     ->text()
 ;
 

 (new PdfSeparate())
    ->setPdf('document.pdf')
    ->setDestination('destination_path/page_%d.pdf')
    ->split();

 PdfSeparate::getOutput('document.pdf','destination_path/page_%d.pdf');
bash
which pdftotext
bash
which which pdfseparate
bash
composer