I need to convert some pdf files into HTML. I downloaded pdftohtml for PHP but I don't know how to use it. I am trying to run it with this code:
<?php
include 'pdf-to-html-master/src/Gufy/PdfToHtml.php';
$pdf = new \Gufy\PdfToHtml;
$pdf->open('1400.pdf');
$pdf->generate();
?>
This results in a blank web page.
What do I need to modify? What is the correct code to run this script?
I use wkhtmltopdf and it works okay. You can download it from here: http://wkhtmltopdf.org/downloads.html
I installed it in Linux and I use it like this:
$url = "https://www.google.com";
$command = "/usr/bin/wkhtmltopdf --load-error-handling ignore --disable-smart-shrinking -T 5mm -B 5mm -L 2mm -R 2mm --page-size Letter --encoding utf-8 --quiet";
$filename = '[file path].pdf';
if (file_exists($filename)) {
unlink($filename);
}
$output = shell_exec($command . " $url " . $filename);
echo $output;
Hope this helps.
First option is using poppler utils
<?php
// if you are using composer, just use this
include 'vendor/autoload.php';
// if not, use this
include 'src/Gufy/PdfToHtml.php';
// initiate
$pdf = new \Gufy\PdfToHtml;
// opening file
$pdf->open('file.pdf');
// set different output directory for generated html files
$pdf->setOutputDirectory('/your/absolute/directory/path');
// do this if you want to convert in the same directory as file.pdf
$pdf->generate();
// you think your generated files is annoying? simple do this to remove the whole files
$pdf->clearOutputDirectory();
?>
Download library from here Second option could be using pdf.js
PDFJS.getDocument('helloworld.pdf')
I'm the maintainer of the package. The package has updated. Have you already used the latest version? And, if you're using Windows, please read again the doc. Also, please do not download directly from github, use composer instead.