Page 290 - Open Soource Technologies 304.indd
P. 290

Web Technologies-I



                   Notes         Introduction

                                 Adobe’s Portable Document Format (PDF) provides a popular way to get a consistent look, both
                                 on screen and when printed, for documents. This chapter shows how to dynamically create PDF
                                 files with text, graphics, bookmarks, and more.

                                 Dynamic construction of PDF files opens the door to many applications. You can create almost
                                 any kind of business document, including form letters, invoices, and receipts. Most paperwork
                                 that involves filling out a paper form can be automated by overlaying text onto a scan of the
                                 paper form and saving the result as a PDF file.

                                 Most people believe PDF files are an electronic replacement for paper. If they create a PDF file
                                 from a scanned document or a Word file to e-mail, they believe the content of that file is locked
                                 down and not editable, just as if they were handing someone a piece of paper. For example,
                                 an individual may write a proposal and “print to PDF” the final version to e-mail to his or her
                                 customer. However, the PDF can still be altered if the recipient has a full version of Adobe
                                 Acrobat. With Acrobat, the recipient can open the PDF, make modifications and resave the PDF
                                 file just as they could with a Microsoft Word document.

                                 So if it’s not like “virtual paper,” then what is a PDF? Essentially it’s a container.
                                    •  Text: such as text in a Word document or text editor, including font information;
                                    •  Pictures: JPG and TIFF images, as well as other file formats, such as a 3D CAD drawing;
                                    •  Metadata: descriptive information, including OCR results that enable the PDF files to be
                                      “full-text searchable.”
                                 What are PDF files?

                                 PDF files (Portable Document Format) allow documents to be read and shared between different
                                 types of applications and computer systems. They are much more suited to longer documents
                                 than a web page is and have the added advantage of being easily printed. The PDF format was
                                 created by Adobe and in order to read PDF documents, you need to install their Adobe Reader
                                 software.

                                 12.1 PDF Extensions

                                 PHP has several libraries for generating PDF documents. It shows how to use the popular pdflib
                                 extension. One drawback of pdflib is that it is not an open source library. Its Aladdin license
                                 allows free personal and noncommercial usage, but for any commercial use you must purchase
                                 a license. Open  source alternatives  include  clibpdf and the  interesting  FreeLibPDF,  which is
                                 written in PHP.
                                 Since pdflib is the most mature and has the most features that are the library. The basic concepts
                                 of the structure and features of a PDF file are common to all the libraries, though.
                                 A number of optional extensions provide PHP with additional functionality. Generally, these
                                 optional extensions are interfaces to third-party code libraries. To use these functions, you need
                                 to install the libraries they depend on and recompile PHP with the appropriate compile-time
                                 directives. Some extensions are given below:
                                 Apache
                                 The Apache library contains functions specific to running PHP under Apache.

                                 This library is available only if PHP is running under the Apache web server. To enable this
                                 extension, you must compile PHP with the with-apache [=DIR] directive.



        284                               LOVELY PROFESSIONAL UNIVERSITY
   285   286   287   288   289   290   291   292   293   294   295