Recommend this page to a friend! |
Download .zip |
Info | Documentation | View files (7) | Download .zip | Reputation | Support forum (6) | Blog | Links |
Last Updated | Ratings | Unique User Downloads | Download Rankings | |||||
2021-05-18 (3 months ago) | 56% | Total: 1,846 This week: 3 | All time: 2,123 This week: 67 |
Version | License | PHP version | Categories | |||
pdf-to-html 1.0.8 | GNU General Publi... | 5.4 | PHP 5, Utilities and Tools, Files and..., C... |
Description | Author | ||||||||
This class can convert PDF to HTML using Poppler program. Recommendations What is the best PHP search string in pdf class? What is the best PHP pdf to text class? What is the best PHP convert pdf to html class? What is the best PHP read pdf file class? Convert PDF to HTML What is the best PHP pdf to html class? What is the best PHP pdf to html class? What is the best PHP convert html to pdf class? PDF to HTML and PDF to JPEG |
|
This PHP class can convert your pdf files to html using poppler-utils.
Big thanks Mochamad Gufron (mgufrone)! I did a packet based on its package (https://github.com/mgufrone/pdf-to-html).
Please see how to use below.
When you are in your active directory apps, you can just run this command to add this package on your app
composer require tonchik-tm/pdf-to-html:~1
Or add this package to your composer.json
{
"tonchik-tm/pdf-to-html":"~1"
}
Debian/Ubuntu
sudo apt-get install poppler-utils
Mac OS X
brew install poppler
Windows
For those who need this package in windows, there is a way. First download poppler-utils for windows here <http://blog.alivate.com.au/poppler-windows/>. And download the latest binary.
After download it, extract it.
Debian/Ubuntu
$ whereis pdftohtml
pdftohtml: /usr/bin/pdftohtml
$ whereis pdfinfo
pdfinfo: /usr/bin/pdfinfo
Mac OS X
$ which pdfinfo
/usr/local/bin/pdfinfo
$ which pdftohtml
/usr/local/bin/pdfinfo
Windows
Go in extracted directory. There will be a directory called bin
. We will need this one.
Example:
<?php
// if you are using composer, just use this
include 'vendor/autoload.php';
// initiate
$pdf = new \TonchikTm\PdfToHtml\Pdf('test.pdf', [
'pdftohtml_path' => '/usr/bin/pdftohtml',
'pdfinfo_path' => '/usr/bin/pdfinfo'
]);
// example for windows
// $pdf = new \TonchikTm\PdfToHtml\Pdf('test.pdf', [
// 'pdftohtml_path' => '/path/to/poppler/bin/pdftohtml.exe',
// 'pdfinfo_path' => '/path/to/poppler/bin/pdfinfo.exe'
// ]);
// get pdf info
$pdfInfo = $pdf->getInfo();
// get count pages
$countPages = $pdf->countPages();
// get content from one page
$contentFirstPage = $pdf->getHtml()->getPage(1);
// get content from all pages and loop for they
foreach ($pdf->getHtml()->getAllPages() as $page) {
echo $page . '<br/>';
}
Full list settings:
<?php
$full_settings = [
'pdftohtml_path' => '/usr/bin/pdftohtml', // path to pdftohtml
'pdfinfo_path' => '/usr/bin/pdfinfo', // path to pdfinfo
'generate' => [ // settings for generating html
'singlePage' => false, // we want separate pages
'imageJpeg' => false, // we want png image
'ignoreImages' => false, // we need images
'zoom' => 1.5, // scale pdf
'noFrames' => false, // we want separate pages
],
'clearAfter' => true, // auto clear output dir (if removeOutputDir==false then output dir will remain)
'removeOutputDir' => true, // remove output dir
'outputDir' => '/tmp/'.uniqid(), // output dir
'html' => [ // settings for processing html
'inlineCss' => true, // replaces css classes to inline css rules
'inlineImages' => true, // looks for images in html and replaces the src attribute to base64 hash
'onlyContent' => true, // takes from html body content only
]
]
Send me an issue for improvement or any buggy thing. I love to help and solve another people problems. Thanks :+1:
Files |
File | Role | Description | ||
---|---|---|---|---|
src (3 files) | ||||
composer.json | Data | Auxiliary data | ||
composer.lock | Data | Auxiliary data | ||
LICENSE | Lic. | License text | ||
README.md | Doc. | Documentation |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
100% |
|
|
User Ratings | User Comments (2) | |||||||||||||||||||||||||||||||||||||
|
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.