Home > Development, English > Choosing a PHP PDF generation library for Chamilo

Choosing a PHP PDF generation library for Chamilo

2014 update: This article is outdated. To date, the library that matches most of the comparison elements below is mPDF. You can include it in your project using Composer: https://packagist.org/packages/mpdf/mpdf

Today (and for the last few days) I am faced with a choice of PDF-generation libraries available in PHP.

The requirements are:

  • GPLv2 or compatible
  • possibility to generate PDF files (obviously) easily
  • possibility to transform an HTML file into a PDF file easily
  • recently developed or still active, with an active community and a possibility to contribute
  • possibility to handle UTF-8

What it can do without being a problem:

  • require PHP5
  • require PHP’s DOM extension
  • require PHP’s PDFlib extension

What it cannot do:

  • require PHP4
  • require anything else than PHP extensions (and the PHP files in the package) (to the exception of font files)
  • have an unclear license
  • have incomplete/unusable documentation

Now the possible libraries that do what I want are:

  • FPDF
  • eZPDF
  • CPDF (from what I read it’s the initial class on which eZPDF was developed, so can be ruled out safely as being too complex)
  • dompdf
  • FPDI (extension built on FPDF to use existing PDF documents as templates, but in itself seems quite useless in our case)
  • TCPDF (extension built on FPDF)
  • PDFlib (ruled out for too strict licensing reasons)
  • PDF PHP (ruled out because it’s just a wrapper for ezpdf)
  • PHP PDF Lib (ruled out because no longer developed)

Let’s analyse them all…

Feature FPDF eZPDF dompdf FPDI TCPDF
License Public domain Public domain LGPL Apache SLv2 LGPL
Easy PDF generation ? yes yes ? ?
Create from HTML no no yes no partial?
Recent activity ? ? yes yes ?
UTF-8 (or -16)? no unclear yes ? yes
Requires PHP5? ? no yes ? no
Requires PHP4? ? no no ? no
Requires DOM ? no yes no no
Requires PDFLib ? no optional no no
Good doc ? yes yes yes yes

The result of all this is that two challengers remain in Dokeos’ case: dompdf and TCPDF.

Considering the conversion from HTML to UTF-8 might be very important in the case of certificates, but that UTF-8 might become very important in the future, and that TCPDF includes UTF-8 handling as well as some HTML elements, I will first give a go to TCPDF and, if satisfying, I will keep to that.

Categories: Development, English Tags: ,
  1. rmerchan
    June 5, 2008 at 6:19 pm

    Nice post, I was just deciding which library was better, you just saved me a lot of time. Thank you!

  2. ywarnier
    June 5, 2008 at 7:30 pm

    I think the UTF-8 support for dompdf has been implemented since, so you might want to consider looking a bit more into this one if that’s one of your criteria. Yes, I just checked and it is now supported (since version 0.5), so I’m updating my table.

  3. pcdinh
    October 17, 2008 at 9:47 pm

    What about Zend_Pdf?

  4. ywarnier
    October 17, 2008 at 9:58 pm

    I didn’t know about it. Would you like to help me put it into the list? Do you know the answers to all the questions (or most of them)?

  5. September 26, 2009 at 3:51 am

    Wonderful list there.. some I’ve never come across before, very useful, Thanks :)

  6. tichi
    April 13, 2012 at 1:14 pm

    thus a good solution at last!

  1. January 30, 2008 at 9:18 pm
  2. April 1, 2009 at 12:22 pm

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: