PHP code example of ibnuhalimm / laravel-pdf-to-html

1. Go to this page and download the library: Download ibnuhalimm/laravel-pdf-to-html 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/ */

    

ibnuhalimm / laravel-pdf-to-html example snippets


use Ibnuhalimm\LaravelPdfToHtml\Facades\PdfToHtml;

$sourceFile = '/path/to/your-file.pdf';
PdfToHtml::setFile($sourceFile)->result();

// It will return output file path
// e.g. : /var/www/html/storage/app/pdf-to-html/your-file.html

use Ibnuhalimm\LaravelPdfToHtml\Facades\PdfToHtml;

$sourceFile = '/path/to/your-file.pdf';
PdfToHtml::setFile($sourceFile)
    ->saveAs('result-file')
    ->result();

// It will return output file path as
// e.g. : /var/www/html/storage/app/pdf-to-html/result-file.html


use Ibnuhalimm\LaravelPdfToHtml\Facades\PdfToHtml;

$sourceFile = '/path/to/your-file.pdf';
PdfToHtml::setFile($sourceFile)
    ->setConfig([
        'bin_path' => '/usr/local/bin/pdftohtml',
        'output_dir' => public_path('/new-location'),
        'inline_images' => false
    ])
    ->result();
bash
which pdftohtml

PDF_TO_HTML_PATH="/usr/bin/pdftohtml"
PDF_TO_HTML_OUTPUT_DIR="/var/www/html/app/public"
PDF_TO_HTML_INLINE_IMAGES=true