Home arrow PHP arrow Anatomy of an Output Class

Anatomy of an Output Class

What should be considered when one in given the task of generating PDF reports? Daryl will explain some aspects that come with this daunting task.

Author Info:
By: Daryl Houston
Rating: 5 stars5 stars5 stars5 stars5 stars / 2
July 16, 2003
  1. · Anatomy of an Output Class
  2. · PDF Basics
  3. · Writing PDFs
  4. · Conclusion

print this article

Anatomy of an Output Class
(Page 1 of 4 )

 Upon changing employers recently, I found that I had inherited a rat's nest of code used to generate project reports in PDF form on the fly. For each of our clients, there were numerous reports, all broken down into individual files with a staggering amount of code duplication and general redundancy. And I had the dubious honor of combing through these files in order to add columns to some tabular reports.

Generating PDFs is nothing like generating HTML. Everything you print to the page is pegged to coordinates on a grid rather than floating freely on the page within vague dimensional constraints. And so adding a column to an existing tabular report in PDF can be a nightmare. 

After spending a frustrating morning crossing my eyes at thousands of lines of code while counting columns and calculating character widths and changing coordinates until the adjustments were finally correct, I decided to write a class that would handle all of this drudgery for me. What's more, I decided that the class should be useful for more than PDF output, and I built in support for HTML, XLS, and XML output as well.

The resulting code itself, while sufficient to handle the bulk of my needs, isn't quite ready for a public consumption yet, but some of the choices (and mistakes) I made while developing it might prove useful to others working on similar tasks. Accordingly, I offer here an account of how I brought an output class to life.

blog comments powered by Disqus

- Removing Singletons in PHP
- Singletons in PHP
- Implement Facebook Javascript SDK with PHP
- Making Usage Statistics in PHP
- Installing PHP under Windows: Further Config...
- File Version Management in PHP
- Statistical View of Data in a Clustered Bar ...
- Creating a Multi-File Upload Script in PHP
- Executing Microsoft SQL Server Stored Proced...
- Code 10x More Efficiently Using Data Access ...
- A Few Tips for Speeding Up PHP Code
- The Modular Web Page
- Quick E-Commerce with PHP and PayPal
- Regression Testing With JMeter
- Building an Iterator with PHP

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 

Developer Shed Affiliates


© 2003-2019 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials