0

I'm currently creating an invoice using FPDF. However, with FPDF there is a lot of calculating and trying before you finally get a decent looking pdf.

My question is if any of you know a good alternative with which I will be able to import html and css. I found some similiar questions on stackoverflow but they were only about importing HTML. I would like for the class to use the css as well. I don't know if this is possible though.

PS: Yes, I Googled it but I can't really seem to find what I'm looking for.

Peter
  • 8,776
  • 6
  • 62
  • 95

1 Answers1

1

There are a few options. You could check out HTML2PDF or mPDF which is based on it, and FPDF. Or, if you find a command line app, such as Prince works better, you could always call this through system calls from your PHP.

When I was in a similar situation I tested these, but in all honesty I found the work I put in to creating a class that extended FPDF, which included things like settings up tables, default styles, etc, actually worked out the best option, as the other results weren't ideal, often creating more work trying to track down things that displayed wrong, particularly for badly-formed or intricate markup or styles.

LeonardChallis
  • 7,759
  • 6
  • 45
  • 76
  • That's what I thought. Every result I checked when googling didn't really meet my expectations. – Peter Dec 17 '14 at 11:54
  • 1
    Yeah, most seem a bit tacky or half-done and not very supported too. To be fair, FPDF does to some extent too. I had a bash at bringing FPDF up to date a little a few years ago to make it easier to use: https://github.com/LeonardChallis/FPDF – LeonardChallis Dec 17 '14 at 11:55