Skip to content
This repository has been archived by the owner on Jun 6, 2020. It is now read-only.

How do i use this? #5

Closed
ThomasRalee opened this issue Oct 4, 2015 · 12 comments
Closed

How do i use this? #5

ThomasRalee opened this issue Oct 4, 2015 · 12 comments

Comments

@ThomasRalee
Copy link

Hi i am trying to figure out how to use this with laravel 5.
This is what i tried to set the bin location... Still not quite sure with the difference between this two. I tried to point the config location to the location my pdf file is residing.

\Gufy\PdfToHtml\Config::set('pdftohtml.bin', '/pdf/');
\Gufy\PdfToHtml\Config::set('pdfinfo.bin', '/pdf/');

It's still returning null for this:

$pdf = new \Gufy\PdfToHtml\Pdf('testing.pdf');

Can someone share with me what went wrong?

Cheers,
Ralee

@ThomasRalee ThomasRalee changed the title Laravel 5 How do i use this? Oct 4, 2015
@mgufrone
Copy link
Owner

mgufrone commented Oct 5, 2015

These codes :

\Gufy\PdfToHtml\Config::set('pdftohtml.bin', '/pdf/');
\Gufy\PdfToHtml\Config::set('pdfinfo.bin', '/pdf/');

are supposed to determine where you locate pdftohtml binary file. so you should appoint it to the binary file, not the directory.

To find it out, you should use

which pdftohtml
which pdfinfo

then use each of locations and insert to the code above. You got what i mean? 👍

@ThomasRalee
Copy link
Author

@mgufrone,
thanks for the reply. I have updated installed Poppler-Utils and updated my codes according to

which pdftohtml
which pdfinfo

Like this

\Gufy\PdfToHtml\Config::set('pdftohtml.bin', '/usr/local/bin/pdfinfo');
\Gufy\PdfToHtml\Config::set('pdfinfo.bin', '/usr/local/bin/pdftohtml');
$pdf = new \Gufy\PdfToHtml\Pdf('/home/vagrant/Code/fyp/public/pdf/testing.pdf');

but it returns this error

ErrorException in Pdf.php line 51:
Undefined index: pages

and when i dd($pdf); it returns null

Can you guide me on the right way of calling the pdf file?
Appreciate your help

Cheers
Ralee

@mgufrone
Copy link
Owner

mgufrone commented Oct 5, 2015

I believe you accidentally flip this code

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

It suppose to be like this

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

Try it again, if it still gives you error, i will check it again.

@ThomasRalee
Copy link
Author

Hey @mgufrone,

Nope flipping it doesnt work. Thanks for helping me.
Same error

ErrorException in Pdf.php line 51:
Undefined index: pages

Cheers,
Ralee

@ThomasRalee
Copy link
Author

Hey @mgufrone,

Any news?

Cheers
Ralee

@mgufrone
Copy link
Owner

mgufrone commented Oct 8, 2015

will give you notice again on a weekend. i hope it will be good news for you.

@ThomasRalee
Copy link
Author

@mgufrone,

I managed to have it worked. I installed poppler utils on my local instead of my virtual machine... Great its working now! Do you know how i can retrieve the html content?

screen shot 2015-10-09 at 12 41 17 am

Great library btw. I am gonna star it now.

Cheers
Ralee

@mgufrone
Copy link
Owner

mgufrone commented Oct 9, 2015

Glad you made it @ThomasRalee 👍
Thank you for using this library.

@afzydev
Copy link

afzydev commented Aug 19, 2016

Hi @mgufrone

Thanks for the great script .

I am getting the same error as above.I have installed sudo apt-get install poppler-utils on local machine.But still getting the same error can you please tell me what else i have to do to convert from PDF to HTML?

Here is code

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


    $viewPdf=public_path().'/assets/uploads/pdf/1dummy.pdf';

    // initiate
    $pdf = new Pdf($viewPdf);

    // convert to html string
    $html = $pdf->html();

@leena123
Copy link

leena123 commented Jun 2, 2017

@ThomasRalee can you please tell me all the configuration settings has been done for using it with laravel
Thanks in advance!!

@sandeep0075
Copy link

finally thanks @mgufrone this is the working code i have

Config::set('/usr/bin/pdftohtml.bin', '/var/www/html/poppler-0.51/bin/pdftohtml.exe');

// change pdfinfo bin location
Config::set('/usr/bin/pdfinfo.bin', '/var/www/html/poppler-0.51/bin/pdfinfo.exe');

thanks a lot

@jineshsubedi
Copy link

jineshsubedi commented Nov 19, 2018

<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>

<?php
use \Gufy\PdfToHtml\Pdf;
use \Gufy\PdfToHtml\Html;

$viewPdf= storage_path('app/public/sample2.pdf');
$pdf = new \Gufy\PdfToHtml\Pdf($viewPdf);

\Gufy\PdfToHtml\Config::set('pdftohtml.bin',storage_path('/app/public/poppler/bin/pdftohtml.exe'));
\Gufy\PdfToHtml\Config::set('pdfinfo.bin',storage_path('/app/public/poppler/bin/pdfinfo.exe'));

$pdf = new Pdf($viewPdf);
$pdfDom = $pdf->getDom(['ignoreImages' => true]);
// convert to html string
$html = $pdf->html();
$dom = $pdf->getDom();
$total_pages = $pdf->getPages();
$paragraphs = $dom->find('body > p');
echo $html;
echo $total_pages;
// echo $paragraphs;
?>
</body>
</html>

worked for me!
download poppler from here - https://blog.alivate.com.au/poppler-windows/

-happy coding jineshsubedi.com.np

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants