3

So lately I've been thinking of building and implementing my own invoice system with PHP and I want to have an optional 'Download/Generate PDF' button that creates a PDF based off of either a template that was created or based off of html/css.

I want a method that is free (seeing as some are ridiculously overpriced) and hopefully not too difficult to use. The end goal is to create something that would be good enough for commercial use (though it's not my intent to sell it).

I've heard of options such as TCPDF, Dompdf, wkhtmlpdf etc. But again I'm looking for one that would render most correct, and potentially be used commercially. I'd like suggestions specifically based off of what I require as I have searched the site for topics that are similar; I'm aware of the different libraries but not sure what I should use.

Thanks in advance! :)

5
  • 2
    now look at right toolbar of this site. and try to use search. Commented Apr 1, 2012 at 21:22
  • Yeah but I want input on what might cater specifically to my needs. Not just generic responses to other people's requirements. Commented Apr 1, 2012 at 21:23
  • try this: mpdf1.com/mpdf Commented Apr 1, 2012 at 21:29
  • I wrote an invoice generator based on PDFlib about a decade ago. Took me weeks to go from zero to a usable invoice. A few years later I rewrote things in FPDF. Took me about two hours. Recently, I migrated to TCPDF, for its integrated barcode support. That migration took about 20 minutes. For my requirements, all solutions worked perfectly; the only difference was ease of use. That's important if you plan to design new layouts more than once. Commented Apr 1, 2012 at 21:40
  • @ghoti Yeah I was actually thinking of eventually making one where 'User A' Can upload a template and download it with their own individual logo,design etc. But that Would be far down the road. I think I'm going to try TCPDF for starters as I start learning more php. Commented Apr 2, 2012 at 1:27

4 Answers 4

4

Having done this a couple times, my suggestion would be to take an existing library that wraps up the low level PDF tools into a decent API, and then build your own library that is specific to your needs (invoicing) on top of it.

I would suggest Zend PDF or TCPDF as a base library to build on. As you add classes to your own library you'll be able to wrap up things like table / line-item generation, headers, footers, etc.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks Brad, I really appreciate the quick response! Zend was something I never really considered for that type of thing. :)
+1 for TCPDF. I've used TCPDF and FPDF. Both are extremely easy to use. FPDF is perhaps marginally simpler, but TCPDF handles Unicode and can draw QR Codes.
2

I used FPDF library, I liked it. http://www.fpdf.org/

and check this manual anyway: http://php.net/manual/en/book.pdf.php

Comments

1

I'm often suspicious about low-level reporting systems (TCPDF et al) - they're very well done, but if a business needs a new report, it can take ages to write code to draw the report to client requirements. I therefore prefer GUI/server solutions, such as iReport (used to design a report) and Jasper (reporting server) - the editability of such a report is near-instantaneous, and thus much more responsive to changing business requirements.

On the plus side, it's free and open source, and on the negative side, you'll need a spare server to run it on. It's Java based, but reports can be run via PHP using SOAP.

Comments

0

If you can use external tools, I recommend wkhtmlpdf. It is really simple to use. Check out the "Integration With PHP" on their wiki: https://code.google.com/p/wkhtmltopdf/wiki/IntegrationWithPhp

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.