Zend
  Home arrow Zend arrow PDFs with PHP part 2
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid  
Request Media Kit
Contact Us  
Site Map  
Privacy Policy  
Support  
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
Google.com  
ZEND

PDFs with PHP part 2
By: Zend
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 5
    2004-01-07


    Table of Contents:
  • PDFs with PHP part 2
  • Color
  • RGB Color
  • Line Drawing
  • Circles
  • Page Add Modifications
  • File Checking
  • Example Use

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article

     
     
    ADVERTISEMENT


    PDFs with PHP part 2
    ( Page 1 of 8 )

    This tutorial is intended for the PHP programmer who needs to incorporate PDF generation in a script without using external libraries such as PDFlib (often unavailable due to licensing restrictions or lack of funds). This tutorial is the second of two parts, and builds on what was covered in the first part. Therefore, if you have not yet gone through Part 1, you are advised to do so (or at least read through it), before going through this tutorial (Part 2). Apart from what was dealt with in Part 1, no knowledge of PDF file structure is required to understand this tutorial, as all references are explained.

    We saw in Part 1 how PDF files are, after all, just plain text files, with specific markup syntax that describes what should happen to objects within the document, such as text and images. We shall now further examine this syntax, to allow us to create a more complete PDF document (i.e more than simple text).

    Learning Objectives
    With the combined knowledge from Part 1, and from the current tutorial (Part 2), you should be able to put together a simple PDF class that can:
      • Add colors to your PDF documents;
      • Add lines, rectangles and circles;
      • Insert JPEG images.

    Prerequisites
    You need to have a fully functional PHP install (either PHP 4 or PHP 5), and a running web server to output the PDF file from your script.

    Acrobat Reader, XPDF, or equivalent is required, to display the results of your work.

    You do not need any external library, either separate or compiled into PHP, to generate your PDF files.

    How It Works
    We already have the class from Part 1 of this tutorial. In Part 2 we will just add a few more class variables and methods to it.

    We shall review the various methods and features of the PDF language, and then finally put it all together as one class.

    New Class Variables
    In addition to the class variables we introduced in Part 1, we will also need the following.
    var $_fill_color = '0 g';  // Color used on text and fills.
    var $_draw_color = '0 G';  // Line draw color.
    var $_line_width = 1;      // Drawing line width.
    var $_images = array();    // An array of used images.
    In the PDF specifications, black is the default value for fill and draw colors, and the default line width is 1 point. Therefore we will use these values as our class defaults for the above variables.



     
     
    >>> More Zend Articles          >>> More By Zend
     

       

    ZEND ARTICLES

    - Taking the Zend Certified PHP Engineer Exam:...
    - Quick Introduction to PHP 5
    - PHP SOAP Extension
    - Improving Performance
    - PDFs with PHP part 2
    - PDFs with PHP part 1
    - PHP at Lycos
    - Build Database Interfaces





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek