HomePHP Working with Images and Text Flows in PDF Files with PHP 5
Working with Images and Text Flows in PDF Files with PHP 5
When it comes to developing database-driven web applications that deliver their contents to end users in a great variety of formats, PHP can be a killer scripting language. This becomes even more evident when these contents must be displayed through one or more PDF files, which have to be built dynamically before being sent to the client. So if you want to learn how to start building PDF documents in PHP 5, then you should begin reading this article now!
Welcome to the third article of the series that began with "Building PDF Documents with PHP 5." Composed of five approachable tutorials, this series takes you through using the most relevant methods that come packaged with the popular "PDFlib" library to create content-rich PDF files directly from inside your own PHP 5 scripts. It complements the corresponding theory with many educational code samples.
Now that you know the subject of this series, I'm going to spend some time refreshing the topics that I covered in the previous tutorial. This will help you to establish an appropriate continuity between it and the current one that you're hopefully reading with interest.
As you'll surely recall, in the second part of the series I showed you how to use a number of straightforward methods that come bundled with the aforementioned "PDFlib" package to build a few basic PDF documents that contained some basic texts. In this case, the text in question was distributed primitively across multiple lines by using a combination of the "set_text_pos()", "show()", and "continue_text()" methods respectively. This came in handy for performing some common tasks, such as specifying what X and Y coordinates should be used on the PDF document to display this text, and that it should be distributed in several chunks of strings.
Of course, due to the easy learning curve offered by many of the methods included with the PDFlib library, performing the tasks from a simple PHP 5 script shouldn't be a major concern for you, and should be tackled with minimal hassles.
So far, so good. At this point, you hopefully recall how to use the previous methods to display multiple lines of text in a concrete PDF file, so it's time to learn a few more method bundled with the library. As you'll see in the next few lines, these methods can be quite helpful for performing other tasks, like including images and blocks of texts into the PDF file in question.
So, are you ready to find out how to incorporate graphics and blocks of strings into a specific PDF document with PHP 5? Well, let's not waste more time in preliminaries and begin this educational journey now!