I am a php web developer and in my one project i need to convert some html document (of 30 to 50 pages) into pdf .
For this I got following some solutions, among them some are php libraries and some are command line applications.
But each has their own advantage and disadvantage.
php libraries: Followings are some php libraries i tried.
- fpdf (need more effort to convert)
- tcpdf (need more effort to convert)
- html2fpdfhtml2fpdf dot sourceforge dot net
- html2pdf html2pdf dot fr/
- dompdf code dot google dot com/p/dompdf/ (compared to other working good)
For each library have problem like:
- Takes long time for conversion process (more than 5min to conert 30 html pages)
Need more resorce (memory and time)
(on my machine i set following parameter in php.ini file: max_execution_time = 600 memory_limit = 250M
but still not work.)
need html pages in well formated (no missing html close tag otherwise gives error)
But when i try all these libraries to convert simple html of 5 or less pages with less css , all works.
Command line application
For command line application , i want to say that all works perfectly and very fast as compared to all above libraries only when i run it directly on console. but when i try to use them in php with exec() or system() function ,gives error.
Following are these command line application and there errors when I run them in php
html2pdf : http://www.tufat.com/s%5Fhtml2ps%5Fhtml2pdf.htm
gives error: html2pdf:11380): Gtk-WARNING **: cannot open display: :0.0
No protocol specified
wkhtmltopdf :
gives error
Loading page: 10%
Loading page: 33%
Loading page: 100%
Waiting for redirect
Outputting pages
QPainter::begin(): Returned false
QPainter::begin(): Returned false
QPainter::save: Painter not active
QPainter::scale: Painter not active
QPainter::setRenderHint: Painter must be active to set rendering hints
QPainter::setBrush: Painter not active
QPainter::pen: Painter not active
QPainter::setPen: Painter not active
htmltopdf : www dot ultrashareware dot com/html-to-pdf.htm
So now I am looking for help.
Can any one answer:
Which php library work good in my case?
Why this errors occur in command line applications?