mgufrone / pdf-to-html

PDF to HTML PHP Class using Poppler-Utils
MIT License
175 stars 88 forks source link

goToPage() throws error #13

Closed altsel closed 8 years ago

altsel commented 8 years ago

First of all thanks for your great work. I will receive the following error when I try to change the page number. If I don't use goToPage() method, page 1 will be rendered correctly.

Fatal error: Uncaught Error: Call to a member function goToPage() on string in /Applications/XAMPP/xamppfiles/htdocs/web/pdftohtml/index.php:17 Stack trace: #0 {main} thrown in /Applications/XAMPP/xamppfiles/htdocs/web/pdftohtml/index.php on line 17

This is my test php file:

<?php // if you are using composer, just use this include 'vendor/autoload.php';

// change pdftohtml bin location \Gufy\PdfToHtml\Config::set('pdftohtml.bin', '/usr/local/bin/pdftohtml');

// change pdfinfo bin location \Gufy\PdfToHtml\Config::set('pdfinfo.bin', '/usr/local/bin/pdfinfo');

// initiate $pdf = new Gufy\PdfToHtml\Pdf('sample.pdf');

// convert to html and return it as Dom Object $html = $pdf->html();

$html->goToPage(3);

echo $html;

$total_pages = $pdf->getPages();

echo $total_pages;

?>

any idea what I am doing wrong ?

thanks

apermo commented 8 years ago

I had the same issue before installing poppler on my mac. Probably you have the same issue.

pauliusjacionis commented 8 years ago

"goToPage" method belongs to Dom Object, but you don't need it just to get raw html. Here's how you can get page 3:

$html = $pdf->html(3);

skilip commented 8 years ago

Could it be that your source PDF file contains spaces?

mgufrone commented 8 years ago

Please test the new tag one. v2.0.7

vikramsingh86 commented 7 years ago

Hi, I have used v2.0.7 on widnows and i am still getting below error: Call to a member function goToPage() on string.

Please help me to sort it out.

Thanks