Creating PDFs with the DOMPDF Spark

The DOMPDF Spark is a great bit of kit; it's simple to set up and can handle most things. It works by grabbing the output of a HTML template file (which you previously created)—you can pass variables to the HTML just as you would with a normal view file—and DOMPDF will create a PDF file from that formatted HTML code.

Getting ready

As this recipe requires the DOMPDF Spark, we'll need to install that into our CodeIgniter instance before we do anything else. To install it, perform the following steps:

  1. Grab the DOMPDF Spark from getsparks.org and install it. Open a terminal window, navigate to your CodeIgniter application directory, and type the following code:
    php tools/spark install dompdf

    That will download the DOMPDF ...

Get CodeIgniter 2 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.