Zend
  Home arrow Zend arrow Page 8 - PDFs with PHP part 1
Dev Shed Forums 
Administration  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Download TestComplete 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
IBM Developerworks
 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? 
ZEND

PDFs with PHP part 1
By: Zend
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 6
    2004-01-06

    Table of Contents:
  • PDFs with PHP part 1
  • Prerequisites
  • The Factory Method
  • Writing Content
  • Adding a Page
  • And Now to Output the Text
  • Closing the Document
  • The Trailer
  • Compression
  • Resources

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb 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

    TestComplete™ automates software testing for a fraction of what the big guys charge. Easy functional and load testing for all Windows, .NET, Java and Web apps. Download a free trial now.

    PDFs with PHP part 1 - The Trailer
    (Page 8 of 10 )

    The final lines to be printed are the PDF trailer.

     
        /* Print trailer. */ 
        $this
    ->_out('trailer'); 
        $this
    ->_out('<<'); 
        
    /* The total number of objects. */ 
        $this
    ->_out('/Size ' . ($this->_n 1)); 
        
    /* The root object. */ 
        $this
    ->_out('/Root ' $this->_n ' 0 R'); 
        
    /* The document information object. */ 
        $this
    ->_out('/Info ' . ($this->_n 1) . ' 0 R'); 
        $this
    ->_out('>>'); 
        $this
    ->_out('startxref'); 
        $this
    ->_out($start_xref);  // Where to find the xref. 
        $this->_out('%%EOF'); 
        $this->_state = 3;         // Set the document state to 
                                   // closed. 



    Now let's look at the new functions we’ve met in this document closing method. The _newobj() function above is used simply to keep track of objects added to the document.



    function _newobj() 

        
    /* Increment the object count. */ 
        $this
    ->_n++; 
        
    /* Save the byte offset of this object. */ 
        $this
    ->_offsets[$this->_n] = strlen($this->_buffer); 
        
    /* Output to buffer. */ 
        $this
    ->_out($this->_n ' 0 obj'); 




    The _putPages() function handles the output of the page content. Here we go through the $_pages array that has been buffering the page content separately, and output it to the main buffer.

    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-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway