Looking for a fast library to render PDF's files with PHP

10,833

Solution 1

In terms of performance wkhtmltopdf seems to be doing well.

It does not rely on PHP to do the heavy lifting, but instead it uses the webkit-engine to render the page.

The downside is that it has not been updated in a while.

Solution 2

Have you tried FPDF ?

FPDF is a PHP class which allows to generate PDF files with pure PHP, that is to say without using the PDFlib library. F from FPDF stands for Free: you may use it for any kind of usage and modify it to suit your needs.

FPDF : class which allows to generate PDF files

You can also use FPDI with FPDF. With FPDI you will be able to import single pages of existing PDF documents into templates.

Solution 3

Try http://www.fpdf.org/

I use it and its very good, flexible, you can set size of a page, you can also use template (fpdi - works with fpdf). You can put images, text, set position of each element.

Solution 4

Some benchmark results:

To renderer this file (with only plain divs) http://dl.dropbox.com/u/15451865/notables_dompdf.html on Intel(R) Core(TM) i7-2600K CPU @ 3.40GHz, 8 GB RAM memory (Ubuntu 12.04):

Dompdf: 35 seconds with a CPU rate of 100%

Google Chrome PDF printer: 1 seconds

So I think DOMPDF is an amazing library but for a service which needs high performance I need another library (I'll try FPDF).

Share:
10,833
alasarr
Author by

alasarr

Software engineer. HTML5 And Cloud developer. System administrator

Updated on July 10, 2022

Comments

  • alasarr
    alasarr almost 2 years

    Does anyone knows about a fast library to render PDF's files with PHP?

    I'm trying with dompdf but it's really slow, it takes about 5 minutes to render a PDF of 23 sheets.

    Dompdf is amazing and really useful, but when you've to render large pdf's files is worthless.

    I'm using dompdf 0.6.0 beta 3.

    Has anyone experimented with larges pdfs in php using another library?

    Could I improve this with dompdf? Here is the html file which dompdf renders:

    http://dl.dropbox.com/u/15451865/pdf.html

    I'm thinking about to write a service with openoffice library but I don't like to use another technology only for this.

  • alasarr
    alasarr almost 12 years
    Thanks, I'm going to test it and I'll post my results
  • Simon Bengtsson
    Simon Bengtsson almost 10 years
    I html table with minimal content and 200 rows times 5 columns took almost 20 seconds to load. I realize this is an old answer, but did you have any luck with FPDF?
  • baldrs
    baldrs about 9 years
    Yes, you just forgot to mention it needs running X server running server-side and performance is awful.
  • Marcel Djaman
    Marcel Djaman almost 8 years
    performance awful? not sure at all! One of best pdf convertor library