Skip to Content
Programming PHP
book

Programming PHP

by Rasmus Lerdorf, Kevin Tatroe
March 2002
Intermediate to advanced
528 pages
21h 29m
English
O'Reilly Media, Inc.
Content preview from Programming PHP

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.

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);

Example 10-12 creates a top-level bookmark named “Countries” and nests two bookmarks, “France” and “New Zealand”, 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.

Example 10-12. Using bookmarks and thumbnails

<?php $p = pdf_new( ); pdf_open_file($p); pdf_begin_page($p,595,842); $top = pdf_add_bookmark($p, "Countries"); $im = pdf_open_png($p, "fr-flag.png"); pdf_add_thumbnail($p, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Programming PHP, 3rd Edition

Programming PHP, 3rd Edition

Rasmus Lerdorf, Kevin Tatroe, Peter MacIntyre
Programming PHP, 2nd Edition

Programming PHP, 2nd Edition

Rasmus Lerdorf, Kevin Tatroe, Peter MacIntyre
Clean Code in PHP

Clean Code in PHP

Carsten Windler, Alexandre Daubois

Publisher Resources

ISBN: 1565926102Supplemental ContentCatalog PageErrata