Pdf Generation Problem

Hi All…

This is my first project with Yii and may be thats the reason I keep on asking very simple and obvious problems… ;) but this time I got stuck with the pdf generation. I already have tried tcpdf extension but I am not satisfied with it at all.

The project in which I am working right now consists mainly of the reports and I want to have a create Pdf link on every page and on the click of that button I want to generate a pdf.

Most of my data is in tabular structure. One of the main problem is that in many reports there are a lot of columns and with tcpdf only a few columns are showing up in the generated page. Moreover the pdf generated has many flaws with the design itself.

I have spent lot of time toying with tcpdf extension but the results are not that satisfactory.

Is there any other feasible way of pdf generation???

I have googled about other ways too. One option that I came across was wkhtmltopdf and the other is dompdf.

Can anyone suggest which one is better

and are the results satisfactory???

Any help will be appreciated

Vatsal

I have the same problem and after one year it seems that there is no a correct solution to the pdf generation. Please let me know if you solved and how did you do it. Regards

We use princexml. Works pretty well. It doesn’t come cheap, though.

actually tcpdf is the way to go. i used it a lot in my web-apps and it is really features rich, robust and well documented library. no need to use the yii extension for this, which actually only wraps it around. just put the class in you components folder and you should be able to derive from it and implement your needed functionality.

the problem with disappearing cell content is one thing i noticed as well and only occurs if you try to render html-cells that are too small for the content. to avoid it just use the TCPDF::Cell() and TCPDF::MultiCell() methods and you should be all right. There’s also a method to check the space a text would occupy so, you can predict if the text will fit into the cell you provide.

maybe there are newer and/or better solutions for generation of pdf from php but this one was the best one a couple of years ago and still produces great results!

PDF generation is one of the few things that really sucks with PHP. As for solutions in the PHP userland, tcpdf is the only viable solution IMHO. The API has grown horribly and it does some questionable things. But in the end, it’s a very mature library. I’ve been most successful by throwing some HTML into it. There’s a binary extension for PHP wrapping around pdflib. But last time I checked, it’s been pretty low-level.

If you are ready to leave the praised land of PHP, there are some other options: A lot of people are invoking LaTeX to generate their PDFs. My current solution is to use Apache FOP and feed it some xsl:fo. That’s sufficient for simple layouts.

At a previous project I had some good experiences with htmldoc. It’s reasonably fast and uses some custom HTML and comments for footers, headers etc.