PHP code example of smalot / pdfparser

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

    

smalot / pdfparser example snippets




use Smalot\PdfParser\Config;
use Smalot\PdfParser\Parser;

// Custom config: Recommended when parsing PDFs from untrusted sources
$config = new Config();

// Cap how far a single stream is decompressed, to avoid memory exhaustion.
// Pick a value that fits your content, and combine it with a sane PHP memory_limit.
$decodeMemoryLimit = 100 * 1024 * 1024; // = 100 MB
$config->setDecodeMemoryLimit($decodeMemoryLimit);

$parser = new Parser([], $config);
$document = $parser->parseFile('/path/to/untrusted-file.pdf');

echo $document->getText();