1

I want to convert any pdf,docx,doc file into html code using php. with same style as in pdf. I am not getting proper solution.

                            Config::set('pdftohtml.bin', 'C:/poppler-0.37/bin/pdftohtml.exe');

                            // change pdfinfo bin location
                            Config::set('pdfinfo.bin', 'C:/poppler-0.37/bin/pdfinfo.exe');
                            // initiate
                            $pdf = new Gufy\PdfToHtml\Pdf($item);

                            // convert to html and return it as [Dom Object](https://github.com/paquettg/php-html-parser)
                            $html = $pdf->html();

Not working for me.

halfer
  • 19,824
  • 17
  • 99
  • 186
viralchampanery
  • 397
  • 1
  • 7
  • 16

3 Answers3

1

I think that this post could help you in a first time. With this one, you'll be able to convert any pdf into HTML code using PHP.

After this, you can use the help provided by this post to convert .doc and .docx to PDF using PHP.

I think that you can now built a function for each document extension that you want to convert into HTML.

Good luck.

Slokilla
  • 11
  • 4
  • Thanks for the pdf to html suggestion,yes its working fine but i lost my style ,paragraph from pdf.. i mean bold,images not coming for the same, please help me out on that – viralchampanery Aug 18 '17 at 09:45
  • Also i think not work on linux server because based on .exe file. – viralchampanery Aug 18 '17 at 09:57
  • I think that a makeshift solution could be to write a dedicated stylesheet, that will match your pdf style. I don't tried to run it on a linux server, but as little this program is, you can just install **wine** on it and run this passthru : `passthru("wine pdftohtml $source_pdf $output_folder/new_file_name",$b)` instead of the actual one. I'll look deeper for your style issue this afternoon. – Slokilla Aug 18 '17 at 11:30
  • Thank you,its helping me alot, will try that too.. mean while i also got good solution for pdfTohtml with css and images https://www.phpclasses.org/package/9423-PHP-Convert-PDF-to-HTML-using-Poppler.html , but i am not getting the solution for second question that is doc,docx to html conversation. if you can put light on it littlebit – viralchampanery Aug 18 '17 at 11:52
1

I had a similar problem and i found a github that i used with word docs. It worked fairly good then but i havent tested it of late. try it.

https://github.com/benbalter/Convert-Word-Documents-to-HTML

Belgarath
  • 104
  • 12
0

I've come across a web service which presents an API for converting documents. I haven't tested it very thoroughly but it does seem to produce decent results at converting Word to HTML:

https://cloudconvert.org/

Sunny
  • 1,504
  • 14
  • 22
  • Thank you, i have successfully, but its paid service...i need something core and also i cannot use on further. i want to search words and highlight , so this solution added extra tags due to that i can not search work – viralchampanery Aug 18 '17 at 11:03