PHP code example of joest8 / pdfinterpreter

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

    

joest8 / pdfinterpreter example snippets



PdfInterpreter\PdfInterpreter;

//get path from terminal: 'echo $PATH'
$path_env = "/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/homebrew/bin:/opt/homebrew/bin";
$pdf = new PdfInterpreter($path_env);


PdfInterpreter\PdfInterpreter;

//get path from terminal: 'echo $PATH'
$path_env = "/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/homebrew/bin:/opt/homebrew/bin";
$pdf = new PdfInterpreter($path_env);

print_r($pdf->get_sample_output());


PdfInterpreter\PdfInterpreter;

//get path from terminal: 'echo $PATH'
$path_env = "/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/homebrew/bin:/opt/homebrew/bin";
$pdf = new PdfInterpreter($path_env);

$pdf->add_new_template("sample","Sample","/[Cc]ompany[\W]?[Aa][Bb][Cc]/","1","eng");

$pdf->add_pattern_to_template("sample","invoice_no","/INVOICE # *([\d]*)/","1");
$pdf->add_pattern_to_template("sample","date","/INVOICE DATE *([\d]{2}.[\d]{2}.[\d]{4})/","1");
$pdf->add_pattern_to_template("sample","positions","/([\d]{1,4}) *(.*?) *([\d]{1,8},[\d]{2}) *([\d]{1,8},[\d]{2})/m","a",true,['pieces','item','price','amount']);

print_r($pdf->get_template("sample"));

print_r($pdf->delete_template("sample"));

print_r(print_r($pdf->convert_folder("/../docs/",true,false,ocr_lang: "eng")));

print_r($pdf->convert_file("/../docs/sample-bill.pdf",true,false));
sh
php install/install_dependencies.php