Home arrow PHP arrow Page 4 - Anatomy of an Output Class
PHP

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
TABLE OF CONTENTS:
  1. · Anatomy of an Output Class
  2. · PDF Basics
  3. · Writing PDFs
  4. · Conclusion

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
Anatomy of an Output Class - Conclusion
(Page 4 of 4 )

Generating "spreadsheet" PDFs can be a real hassle, and I sought to relieve myself of that hassle by writing an Output class, which is itself far from perfect. For larger data sets or for PDFs that don't follow the format of a (potentially) multi-page set of rows and columns of data, my class is of limited use. I suspect that a number of the methods I've used to perform certain tasks could be optimized or reworked to be more user-friendly, and I won't release any code until I've had a chance to do that reworking. 

I offer this summary of my efforts, with particular emphasis on the parts of the class that gave me problems, in hopes that it may be useful to others developing similar pieces of code. My primary flaw was one of design -- I hadn't fully considered some of the problems that might arise before I waded in and developed the first draft of the class. I have attempted here to expose some of the issues that escaped my initial attention and to offer groundwork toward workable solutions for those issues.

The end result has been very satisfying for me. Where before, the creation of a new PDF report meant copying an old report and spending a few hours doing the tedious work of tweaking widths and positions buried in a couple of thousands of lines of code, I can now copy the above code sample, apply a few tweaks to handle data formatting and building of graphs, and be done with it. 

Time for development of our routine reports has been reduced significantly, and code maintenance is much easier. The class is currently about 1150 lines. (The graph code itself is about 200 lines.) Of course, that count includes code for the other three types of output as well, along with ample comments. The code is cleaner and much more portable than what we had been using before building the class. With all its headaches and boils and bruises, the Output class has proven most beneficial.

Note

In retrospect, this could stand to be changed. The value should always be in the value field instead of crossing over this way.


DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

blog comments powered by Disqus
PHP ARTICLES

- 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

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



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