Home arrow PHP arrow Drawing Basic Rectangles in PDF Documents with PHP 5

Drawing Basic Rectangles in PDF Documents with PHP 5

If you’re a PHP developer who’s searching for a friendly guide on how to build dynamic PDF files within your PHP 5-based applications, then look no further, and start reading this series now!

TABLE OF CONTENTS:
  1. Drawing Basic Rectangles in PDF Documents with PHP 5
  2. Adding an image and a text flow to a PDF file
  3. Drawing some basic rectangles
  4. Displaying multiple rectangles on the same PDF file
By: Alejandro Gervasio
Rating: starstarstarstarstar / 2
November 20, 2007

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

Welcome to the fourth part of the series that began with “Building PDF documents with PHP 5.” Since PHP 5 comes packaged with robust capabilities for delivering database contents in a considerable variety of formats, including Adobe’s PDF (Portable Document Format), this series teaches you how to create this type of file with only minor hassles, directly from your own scripts.

If you already read the two preceding tutorials of the series, you’ve acquired a solid background in building simple PDF documents with PHP 5. In those articles I covered the basics of this process, including the adequate implementation of the “set_text_pos()”, “show()”, and “continue_text()” methods that come integrated with the PDFLib library. I did this in order to display both single and multi-line texts, as well as incorporate some basic images into a given PDF document.

Creating dynamic PDF files is a process reduced to spawning an instance of the already familiar PDFLib class, bundled with the homonymous library, and then calling the appropriate set of methods in accordance with the kind of tasks that must be performed on the file in question, such as opening a new document and a new page, adding some lines of text, including images, you name it.

In addition, you’ll certainly recall that in the previous installment of the series I showed you how to create different blocks of text inside a determined PDF document, which in this context are called “text flows.” As you saw, these text flows are useful when you want to incorporate several paragraphs that have predefined dimensions -- that have specific widths and heights respectively.

Regarding the incorporation of text flows into a given PDF document, I showed a concrete example of how to use a combination of the handy “create_text_flow()”, “fit_text_flow()”, and “delete_text_flow()” methods, to display a single block of text at a specific position within the pertinent document. Certainly this is a procedure that can be performed effortlessly, mostly because of the easy learning curve offered by the aforementioned methods.

All right, now that you know how to include basic blocks of text into a simple PDF file, in addition to incorporating some images, the question that comes up here is: what’s the next step to take? Well, in this fourth part of the series I’m going to show you how to draw a few basic shapes, once a PDF document has been opened, like empty and filled rectangles, which can be useful if you want to decorate the document with these kinds of forms.

Now, let’s get rid of the boring preliminaries and start learning more about how to draw a few simple rectangles in a specific PDF file. Let’s get going!



 
 
>>> More PHP Articles          >>> More By Alejandro Gervasio
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PHP ARTICLES

- Hackers Compromise PHP Sites to Launch Attac...
- Red Hat, Zend Form OpenShift PaaS Alliance
- PHP IDE News
- BCD, Zend Extend PHP Partnership
- PHP FAQ Highlight
- PHP Creator Didn't Set Out to Create a Langu...
- PHP Trends Revealed in Zend Study
- PHP: Best Methods for Running Scheduled Jobs
- PHP Array Functions: array_change_key_case
- PHP array_combine Function
- PHP array_chunk Function
- PHP Closures as View Helpers: Lazy-Loading F...
- Using PHP Closures as View Helpers
- PHP File and Operating System Program Execut...
- PHP: Effects of Wrapping Code in Class Const...

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: