Pages

Sunday, April 18, 2010

PHP and PDF not a big deal !!

I was looking for a smart pdf solution  which can be used from php code. There are plenty of solution out there.dompdf,fpdf etc. I tested few of them. Each one has its own limitations. Some wont work good with the images, some will create ugly pdf  if you have nested tables etc. Most of these free code snippets were pretty old. Finally  my eyes caught attention of wkhtmltopdf. This was part of google open source code  base, and more over there are more frequent releases. one in 2010 too. My initial tests gave me wonderful results.But there was more hurdles to face. All the examples shown were converting a http location like www.yahoo.com  or  a static html page. on the contrary my need was to convert a user filled form to a pdf doc on the fly. I thought of lots solutions to tackle this issue.converting the user entered forms in to a static html page in the server . Of course who will clean up the orphan files . Another big problem was wkhtmltopdf  was a commandline  executable. how can we call an executable from a php code. I tried lots of combination together. finally I was able to solve the puzzle with bits and pieces. If you are interested in my solution please leave me a comment. I will be more than happy to help you out!  I am tired going to bed for a nice sleep. 
Related Posts Plugin for WordPress, Blogger...