tonchik-tm / pdf-to-html

This PHP class can convert your pdf files to html using poppler-utils.
MIT License
54 stars 30 forks source link

Only variables should be passed by reference #1

Closed barnabaskecskes closed 8 years ago

barnabaskecskes commented 9 years ago

I'm having an issue when calling the getHtml() method. See image below - help would be appreciated. :)

screen shot 2015-09-17 at 23 18 13
KenFlip commented 8 years ago

Hi,

I know its a year afterwards but im having issues with this, please se below:

// initiate
include 'vendor/autoload.php';
$pdf = new \TonchikTm\PdfToHtml\Pdf(BASE_PATH . 'uploads/pdf/test.pdf', [
    'pdftohtml_path' => '/usr/bin/pdftohtml',
    'pdfinfo_path' => '/usr/bin/pdfinfo'
]);

// 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/>';
}

And this is the output i am getting:

Notice: Undefined index: pages in /Users/Tin/Documents/Work/flipswitch-framework/vendor/tonchik-tm/pdf-to-html/src/Pdf.php on line 81

Strict Standards: Only variables should be passed by reference in /Users/Tin/Documents/Work/flipswitch-framework/vendor/tonchik-tm/pdf-to-html/src/Pdf.php on line 178

Notice: Undefined index: pages in /Users/Tin/Documents/Work/flipswitch-framework/vendor/tonchik-tm/pdf-to-html/src/Pdf.php on line 81

Strict Standards: Only variables should be passed by reference in /Users/Tin/Documents/Work/flipswitch-framework/vendor/tonchik-tm/pdf-to-html/src/Pdf.php on line 178

Notice: Undefined index: pages in /Users/Tin/Documents/Work/flipswitch-framework/vendor/tonchik-tm/pdf-to-html/src/Pdf.php on line 81

This is really really urgent as I need to get this done by today, please advise asap 👍

daviddebeer commented 8 years ago

Ok, I had this issue and after a bit of research I have found the answer: Under strict conditions the first variable in the array_walk function is not actually a variable. so to fix change the following line(s) of code in the Pdf class: "array_walk($this->getOptions('generate'), function ($value, $key) use (&$generated) {"

to

"$getOptions = $this->getOptions('generate'); array_walk($getOptions, function ($value, $key) use (&$generated) {"

tonchik-tm commented 8 years ago

Done

atif-kht commented 7 years ago

I am still getting this issue and no html is generated:

Undefined index: pages in F:\wamp\www\pdf2htmltonchik\vendor\tonchik-tm\pdf-to-html\src\Pdf.php on line 81