wbrframe / pdf-to-html
PDF to HTML converter with PHP using tools, like poppler-utils
This package's canonical repository appears to be gone and the package has been frozen as a result.
Requires
- php: ^7.0
- symfony/dom-crawler: ^5.0
- symfony/filesystem: ^5.0
- symfony/process: ^5.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.16
- phpstan/phpstan: ^0.12.18
This package is auto-updated.
Last update: 2023-12-29 03:31:42 UTC
README
PDF to HTML converter with PHP using tools, like poppler-utils. Currently only supported poppler-utils.
Important
PdfToHtml from package poppler-utils always executing with next flags:
-s
# single file-i
# without images-noframes
# without iframe
Installation
When you are in your active directory apps, you can just run this command to add this package on your app
composer req wbrframe/pdf-to-html
Requirements
- Poppler-Utils (if you are using Ubuntu Distro, just install it from apt )
sudo apt-get install poppler-utils
Usage
In this example HTML file will be created in system temporary folder with in subfolder output
a random name.
Example: /tmp/output/5e8671ec8e0283.34152860.html
<?php use Wbrframe\PdfToHtml\Converter\ConverterFactory; // if you are using composer, just use this include 'vendor/autoload.php'; // initiate $converterFactory = new ConverterFactory('test.pdf'); $converter = $converterFactory->createPdfToHtml(); $html = $converter->createHtml(); // Get absolute path created HTML file $htmlFilePath = $html->getFilePath(); // or get Crawler (symfony/dom-crawler) $crawler = $html->createCrawler(); ?>
You can change some options like is outputFolder
, outputFilePath
and binPath
, where an option outputFolder
is folder were HTML will be created,
outputFilePath
is absolute path for HTML file that you want to create, binPath
is path to pdftohtml
NOTE: If outputFilePath
is specified, option an outputFolder
is was be missed.
<?php use Wbrframe\PdfToHtml\Converter\ConverterFactory; use Wbrframe\PdfToHtml\Converter\PopplerUtils\PdfToHtmlOptions; // if you are using composer, just use this include 'vendor/autoload.php'; $converterFactory = new ConverterFactory('test.pdf'); $options = (new PdfToHtmlOptions()) ->setBinPath('/path/pdftohtml') ->setOutputFolder('/app/output') ->setOutputFilePath('/app/output/file.html') ; $converter = $converterFactory->createPdfToHtml($options); $html = $converter->createHtml(); ?>