Skip to main content


developerWorks  >  Open source  >

Understanding the Zend Framework, Part 5: Creating PDF files

Building the perfect reader

developerWorks

Level: Intermediate

Nicholas Chase (ibmquestions@nicholaschase.com), Consultant, Backstop Media

01 Aug 2006

Register now or sign in using your IBM ID and password.

In previous parts of this "Understanding the Zend Framework" series, we created the basic application, the Chomp online feed reader, using the open source PHP Zend Framework. In this tutorial, we use the Zend Framework's PDF capabilities to generate a PDF document based on entries the user has saved.

In this tutorial

Over the course of this tutorial, you will learn how to create a PDF document with the Zend Framework; use positioning within a PDF document; add text, graphics,shapes, and information to a PDF document; manage long blocks of text in a PDF document; and stream a dynamic PDF document to the browser.


Prerequisites

This tutorial assumes that you have a good familiarity with PHP programming and at least a basic understanding of how the Model-View-Controller (MVC) pattern works. You do not have to know what the format of a PDF document looks like; the whole point of the Zend_PDF component is to insulate you from that depth of involvement with your data.


System requirements

To follow along, you will need to have several pieces of software installed. This tutorial will cover installation and configuration, but make sure to download the following pieces of software. For detailed installation instructions, see Part 2 of this series.

Apache HTTP Server
Theoretically, you can use any HTTP server that supports PHP, but you will also need to make use of the mod_rewrite module in order to make the MVC functionality of the Zend Framework work, so you will probably want to use Apache. For Microsoft® Windows®, make sure to download a version of Apache that is supported by PHP V5 as a module. (This tutorial only covers module installation; if you want to install PHP as a CGI program, you're on your own.) At the time of this writing, that means Apache V2.0, not Apache V2.2. This tutorial was tested on Windows with Apache V2.0.58.
PHP V5
This framework requires the functionality of PHP V5.0 and higher. However, you should go with 5.1 or higher because it also uses PHP Data Objects (PDO), which come with that version. This tutorial was tested using V5.1.4.
Zend Framework
This set of PHP classes is where all the work will be done. The framework is still at an early stage, even though it does include quite a lot of functionality. This tutorial was tested with V0.1.3.
MySQL
Ultimately, you may use the Zend Framework with any database for which an adapter exists, and the database functionality will work the same way. That said, at the time of this writing, your choices are somewhat limited. This tutorial uses the MySQL database, tested with V4.0.21, but later versions should work.
WAMP
This is an easy-to-install version of Apache, MySQL, and PHP rolled into one package.
Adobe Acrobat Reader
You need the Adobe Acrobat Reader to read the documents we create.

For a step-by-step guide to installing the individual pieces -- Apache, PHP, and MySQL -- on either Windows or Linux®, check out this screen cast.



Formats

html, pdf


Share this....

digg Digg this story del.icio.us del.icio.us Slashdot Slashdot it!


Back to top


Document options

Document options requiring JavaScript are not displayed


More in this series:
Understanding the Zend Framework