1. Go to this page and download the library: Download xxxwer/pdftohtml-poppler 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/ */
xxxwer / pdftohtml-poppler example snippets
// if you are using composer, just use this
'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_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
]
]
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.