10

I have a PHP application and a need to generate a PDF with the result of query. The easiest way a found to do this was to use the DOMPDF to generate the PDF for me. So a made a function that generates the HTML for me then a pass this to DOMPDF. In the development and testing enviroment everything was fine but on production enviroment I had some problems with memory usage.

So I would like to know if my strategy was the best one or if there's a better and easy way to do this.

How would you do that?

John Topley
  • 113,588
  • 46
  • 195
  • 237
Luiz Guilherme
  • 1,601
  • 21
  • 37

6 Answers6

15

I once did a PHP project generating PDF. I used FPdf.

I never had any memory problems. It's free, it's pure PHP code. You don't have to load any extensions.

I don't know if there's some helpers to auto-generate document from a query, but in the website, you have some scripts that shows how to use it with MySql.

HTH

vIceBerg
  • 4,197
  • 5
  • 40
  • 53
1

I'm amazed nobody uses FOP:) http://xmlgraphics.apache.org/fop/ ... you basically feed it an XML flie and it generates a PDF file... very quick, and dosent kill your server.

Quamis
  • 10,924
  • 12
  • 50
  • 66
0

Fll out a latex template and call Xetex over it.

I think you'll find the results pleasing at Letterly.

hendry
  • 9,725
  • 18
  • 81
  • 139
0

There is a PDF extension for PHP but it's not great - however the Zend framework does have a class that makes good use of it - I reccommend trying that. I haven't heard of DOMPDF before.

Ross
  • 46,186
  • 39
  • 120
  • 173
0

I use EZPDF pretty much weekly. It's very easy to use, has great helper functions, but still lets you get in & do the nitty gritty detail work when you have to.

MattBelanger
  • 5,280
  • 6
  • 37
  • 34
0

PrinceXML is a good alternative. It can cost a bit, but very powerful and easy to use.

James Hall
  • 7,507
  • 2
  • 22
  • 15