Convert reports generated in PHP/MySQL/HTML to PDF format on a Mac
I'm working on some pages that开发者_如何学Python combine html, php, and mysql to create reports from a mysql database. I'd like to be able to create a button to convert these reports to PDF files for the user to download. Any idea of how to approach this (on a Mac, I might add)?
Thanks!
I've used PDFlib a lot in my projects. You can build PDFs from the ground up programmatically, or use a template PDF and add new things on top of that. The downside is that it's a commercial library, and the licensing cost is fairly steep.
You can use libraries to allow you to create pdf files directly on your server side. The most recommended one for such use is tcpdf. This will allow you to custom format your reposrt and then convert them to pdf on the fly.
We use TCPDF for some of our reports. It's pretty simple PHP syntax, not hard to figure out, but it is a tad limited. I've heard good things about FPDF as well, which seems to have a few more features and is about as easy to use.
Unfortunately, you probably won't find much more than that using just PHP. You could generate XML/XDP files to populate a pre-made PDF file (we do this on one such report), but it introduces extra steps and large possibilities for glitches.
精彩评论