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

Unit 12: Portable Document Format



                                                                                                  Notes
                                     Figure 12.13: A Templated Page





                                         pdfTemplate Example
























            Some operations, such as opening an image, cannot be done within the context of a template
            definition. Attempting to do so will cause an error. If you get such an error, simply move the
            offending operation to just before the pdf_begin_template( ) call.

            12.5 Navigation


            PDF provides several navigation features for PDF files. Bookmarks function as a table of contents
            for the document, and you can provide viewers with thumbnail images indicating what’s at the
            other end of each bookmark. In addition, any part of a PDF page can be linked to another part
            of the current PDF file, another PDF file, or a completely different file.

            12.5.1 Bookmarks and Thumbnails
            Bookmarks make it easy to quickly navigate through long PDF documents. You can create a
            bookmark with the pdf_add_bookmark( ) function, which returns a bookmark handle:
            $bookmark = pdf_add_bookmark(pdf, text, parent, open);

            The text parameter is the label that the user sees. To create a nested menu of bookmarks, pass
            a bookmark handle as the parent option. The current location in the PDF file (as it is being
            created) is the destination of the bookmark.

            Bookmarks can have thumbnails associated with them. To make a thumbnail, load an image
            and call pdf_add_thumbnail( ):
            pdf_add_thumbnail(pdf, image);

            The Example creates a top-level bookmark named “Countries” and nests two bookmarks,
            “France” and “India”, under the “Countries” bookmark. It also creates a representative thumbnail
            image for each page. These thumbnails can be viewed in Acrobat Reader’s thumbnail panel.





                                             LOVELY PROFESSIONAL UNIVERSITY                                   309
   310   311   312   313   314   315   316   317   318   319   320