Zend
  Home arrow Zend arrow Page 8 - PDFs with PHP part 2
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 
 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 2
By: Zend
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 4
    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:
      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 2 - Example Use
    (Page 8 of 8 )


    The new example script below includes the added functions. It sets different colors, draws some lines, a rectangle and a circle, and uploads an image. Note how we can use line drawing to emulate underline, which is not natively available in the PDF syntax.


    <?php 
    require 
    'PDF.php';                    // Require the class. 
    $pdf = &PDF::factory('p', 'a4');      // Set up the pdf object. 
    $pdf->open();                         // Start the document. 
    $pdf->setCompression(true);           // Activate compression. 
    $pdf->addPage();                      // Start a page. 
    $pdf->setFont('Courier', '', 8);      // Set font to courier 8 pt. 
    $pdf->text(100, 100, 'First page');   // Text at x=100 and y=100. 
    $pdf->setFontSize(20);                // Set font size to 20 pt. 
    $pdf->setFillColor('rgb', 1, 0, 0);   // Set text color to red. 
    $pdf->text(100, 200, 'HELLO WORLD!'); // Text at x=100 and y=200. 
    $pdf->setDrawColor('rgb'001);   // Set draw color to blue. 
    $pdf->line(100, 202, 240, 202);       // Draw a line. 
    $pdf->setFillColor('rgb', 1, 1, 0);   // Set fill/text to yellow. 
    $pdf->rect(200, 300, 100, 100, 'fd'); // Draw a filled rectangle. 
    $pdf->addPage();                      // Add a new page. 
    $pdf->setFont('Arial''BI'12);     // Set font to arial bold 
                                          // italic 12 pt. 
    $pdf->text(100, 100, 'Second page');  // Text at x=100 and y=100. 
    $pdf->image('sample.jpg', 50, 200);   // Image at x=50 and y=200. 
    $pdf->setLineWidth(4);                // Set line width to 4 pt. 
    $pdf->circle(200, 300, 150, 'd');     // Draw a non-filled 
                                          // circle. 
    $pdf->output('foo.pdf');              // Output the file named foo.pdf 
    ? > 


     


    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.

     

       

    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 4 hosted by Hostway