Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

Understanding the Zend Framework, Part 5: Creating PDF files

Building the perfect reader

Nicholas Chase (nicholas@nicholaschase.com), Developer/Writer, Studio B
Nicholas Chase, a Studio B author, has been involved in Web site development for companies such as Lucent Technologies, Sun Microsystems, Oracle, and the Tampa Bay Buccaneers. Nick has been a high school physics teacher, a low-level radioactive waste facility manager, an online science fiction magazine editor, a multimedia engineer, and an Oracle instructor. More recently, he was the Chief Technology Officer of an interactive communications firm in Clearwater, Florida, USA, and is the author of several books on Web development, including XML Primer Plus (Sams). He's currently trying to buy a farm so he and his wife can raise alpacas and chickens. He loves to hear from readers and can be reached at: nicholas@nicholaschase.com.

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

View more content in this series

Date:  18 Jan 2011 (Published 01 Aug 2006)
Level:  Intermediate PDF:  A4 and Letter (736 KB | 40 pages)Get Adobe® Reader®

Activity:  34166 views
Comments:  

Before you start

This tutorial is for developers who want to learn more about generating PDF files using the PHP Zend Framework. It discusses the overall framework and provides an example of generating new and edited documents. This functionality will be integrated into the existing Chomp feed reader created earlier in this series.

About this series

This "Understanding the Zend Framework" series chronicles the building of an online feed reader, Chomp, while explaining the major aspects of using the recently introduced open source PHP Zend Framework.

Part 1, talked about the overall concepts of the Zend Framework, including a list of relevant classes and a general discussion of the MVC pattern. Part 2 expanded on that to show how MVC can be implemented in a Zend Framework application. You also created the user registration and login process, adding user information to the database and pulling it back out again.

Parts 3 and 4 dealt with the actual RSS and Atom feeds. In Part 3, you enabled users to subscribe to individual feeds and to display the items listed in those feeds. You also discussed some of the Zend Framework's form-handling capabilities, validating data, and sanitizing feed items. Part 4 explained how to create a proxy to pull data from a site that has no feed.

The rest of the series involves adding value to the Chomp application. Here in Part 5, you will look at using the PDF format as a type of backup for saved entries. Part 6 uses the Zend_Mail module to alert users to new posts. Part 7, looks at searching saved content and returning ranked results. In Part 8, you create your own mashup, adding information from Amazon, Flickr, Twitter and Yahoo! And in Part 9, you add Ajax interactions to the site using JavaScript object notation.


About this tutorial

In earlier parts of this "Understanding the Zend Framework" series, you created the basic Chomp online feed reader.

In this tutorial, you will provide a way for the user to create a PDF file of his favorite feed entries. The user can then download the PDF as a backup or as a more convenient way to print out multiple entries to read later.

You'll start by creating a basic PDF document using the Zend_PDF component of the Zend Framework, enabling you to see the general concepts behind creating a document, adding text and graphics, and more. You will then look at integrating this functionality with the application.

To do that, you will first make it possible to save descriptions to the savedentries table, which previously held only full text (web page) entries. This will make them available for adding to the PDF document. You will then look at creating a new PDF document from within the feed controller and adding actual live data to it. You will also look at solving several issues that arise from the lack of features that are often taken for granted, such as word wrapping at the end of a line.

In this tutorial, you will take the existing code from Part 4 and enable the user to save his existing saved entries in a single PDF document, which can be read offline or printed.


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 (see Resources). 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.

See Part 2 of this series for details on installing the Zend Framework and XAMPP, the easy-to-install version of Apache, MySQL, and PHP rolled into one.

1 of 9 | Next

Comments



Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Open source
ArticleID=148418
TutorialTitle=Understanding the Zend Framework, Part 5: Creating PDF files
publish-date=01182011
author1-email=nicholas@nicholaschase.com
author1-email-cc=dwxed@us.ibm.com

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere).

My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Try IBM PureSystems. No charge.