2

I'm looking to write HTML tables, which contain PHP variables inside the columns, to a unique PDF file. From the way it looks, there's no way to simply write an HTML table to a PDF file. Does anyone have any tools that do this, or a script that would point me in the right direction?

Thanks!

Zack Tanner
  • 2,560
  • 1
  • 29
  • 45

2 Answers2

3

You might want to check out dompdf

julesj
  • 754
  • 4
  • 10
1

I've recently been testing DomPDF (as mentioned by julesj) and mPDF as alternatives to tcPDF. I encountered a few problems with html tables when using DomPDF (e.g. missing the first row on each page), and found mPDF fractionally faster, but needing significantly more memory. However, the generated PDF file was much cleaner than that generated using DomPDF. Conversely, DomPDF has a much smaller disk size footprint.

Mark Baker
  • 209,507
  • 32
  • 346
  • 385
  • dompdf definitely still needs a bit of work around tables. I haven't seen the issue you cite (missing first row), but the biggest problems surrounding tables are: a) losing column alignment across pages, b) not being able to split a row/cell into two ... resulting in either large gaps at the bottom of a page or in the worst case an infinite loop. There are other, less serious issues around tables but those are the biggest. – BrianS Feb 04 '11 at 17:40
  • The DomPDF developers do seem very active, and potentially the HTML to PDF could become a very good feature, but I think it still needs a bit of work before it reaches that stage.... one to keep an eye on for the future. – Mark Baker Feb 04 '11 at 19:24