0

I am creating an invoicing application that generates a dynamic invoice via php/mysql in the browser windows. Tables and css are part of the makeup.

I was thinking it would be nice to have a button that when clicked, a popup would appear asking you to save a pdf to your computer.

Can someone steer me in the right direction?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Tom
  • 363
  • 2
  • 11
  • 21

1 Answers1

3

These might be of help:

  • fpdf - PHP class-based generator
  • wkhtmltopdf - Convert html to pdf using webkit (qtwebkit)
  • mPDF - PHP class which generates PDF files from UTF-8 encoded HTML
  • TCPDF - an enhanced and maintained version of fpdf
  • dompdf - (mostly) CSS 2.1 compliant HTML layout and rendering engine
  • Zend_Pdf - A PDF manipulation engine/component from Zend
  • PrinceXML - Commercial, but supports CSS3 transforms

It's partly dependent on how complex the HTML is and what you want to display. Some of them can be a bit flaky when rendering certain style-based elements (especially CSS2/CSS3), but in general they are pretty good.

If you're planning to "force-download" your PDFs, then you'll need to use something like the following in PHP:

  header('Content-disposition: attachment; filename=filename.pdf');

A good example/explanation can be found in a previous SO answer: php: force download to harddrive?

Community
  • 1
  • 1
nickhar
  • 19,981
  • 12
  • 60
  • 73
  • Not to forget PDFlib.com - Fast enterprise class-based engine for PDF-Creation – heiglandreas Mar 31 '13 at 06:56
  • Thanks for the responses. Here is where I am at. I could not get mpdf to work, and it looks promising as you just call the code from within your php. tcpdf looks promising to, however you have to re-write your php code to work with it. Still working on testing out the other suggestions. – Tom Mar 31 '13 at 20:42