ibnuhalimm / laravel-pdf-to-html
Laravel Wrapper to Convert PDF to HTML
Installs: 6 069
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 3
Open Issues: 2
Requires
- php: ^7.4|^8.0
- illuminate/support: ^8.0|^9.0|^10.0
- symfony/process: ^4.0|^5.0|^6.0
Requires (Dev)
- orchestra/testbench: ^6.0
- phpunit/phpunit: ^9.0
README
Convert PDF to HTML by using pdftohtml on Your Laravel Apps. Special thanks to pdf-to-text (Spatie) package for inspiring this package.
Contents
Requirements
Behind the scene this package leverages pdftohtml. You can verify if the binary installed on your system by executing this command.
which pdftohtml
If it doesn't return the installed path of the binary, you can install the binary using the following command.
- Ubuntu and Debian family
apt-get install poppler-utils
- CentOS, Fedora, and RedHat family
yum install poppler-utils
- Mac using brew
brew install poppler
Installation
You can install the package via composer:
composer require ibnuhalimm/laravel-pdf-to-html
Setting Up
Optionally, you can set the config in your .env
file:
PDF_TO_HTML_PATH="/usr/bin/pdftohtml"
PDF_TO_HTML_OUTPUT_DIR="/var/www/html/app/public"
PDF_TO_HTML_INLINE_IMAGES=true
Usage
Set the file and get result
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
Save as the result file
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
We can set config on-the-fly
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();
Testing
composer test
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email ibnuhalim@pm.me instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
Laravel Package Boilerplate
This package was generated using the Laravel Package Boilerplate.