tags:

views:

52

answers:

2

Hi,

I have a PHP program that reads from the database and generated formatted sheets. The sheet is one for each person in the database. So, I thought the best way is to convert each into a PDF because this way I don't have to worry about headers, footers and the margins that the printer adds automatically.

I have used DOMPDF for this task but found that I need to generate one PDF per person because it constantly crashes complaining not enough memory. That is fine, except for now one will have to click links one by one to retrieve the all the PDFs.

Is there a better way to achieve this task? Is there a better HTML to PDF library around? If not, maybe there is a way to combine all the individual PDFs into one?

If I had to forget about the HTML to PDF convertor, that means I will write PDF directly. Most of the PDF libraries in PHP seems to require you to completely forget about the document structures, and write everything as texts. Not sure if that's a good thing.

thanks a lot, YJ

A: 

I recommend to use TCPDF or html2pdf. And if you want to merge your pdfs into one, use pdftk.

To merge your pdfs into one pdf using pdftk:

 passthru("pdftk 1.pdf 2.pdf etc.pdf output merge.pdf");
Manie
Note: Don't forget to install pdftk in your system to make this code works..
Manie
The pdftk works great. Thanks a lot!
Y.J.
A: 

Is there a better HTML to PDF library around?

Lots. Check out this list of HTML-to-PDF converters. It's worth noting that the best ones are not native PHP.

Charles
Thanks for the link.
Y.J.