Adding Hyperlinks to PDFs


Some PDF readers allow you to navigate using hyperlinks attached to hot spots in the PDF. Quartz 2D can annotate its metafiles with hyperlinks as well. The Quartz 2D API allows you to create hyperlinks both to locations within the PDF document and to URLs that are external to the PDF.

Internal Links

Creating a link within a PDF document is a two-step process. The first step is to annotate the PDF document with anchor points. An anchor point is simply a named location in the document that is the destination of an internal link. Quartz 2D allows you to create an anchor point anywhere on a page. The routine that creates an anchor point is CGPDFContextAddDestinationAtPoint. This routine accepts the name of the anchor point and its location on the current page.

To identify a hot spot in the PDF that will take you to an anchor point, your application can call the routine CGPDFContextSetDestinationForRect. This routine accepts the rectangle on the current page that becomes the hot spot. It also accepts the name of the anchor that is the destination of the link.

URL Hyperlinks

In addition to hyperlinks that navigate within a document, Quartz 2D allows you to add hyperlinks to network URLs. To create a URL hot spot, you call the Quartz routine CGPDFContextSetURLForRect. This function accepts the URL that is the destination of the hyperlink and a rectangle on the current page as parameters. The area under the rectangle becomes a hot spot in the resulting PDF.

Quartz 2D is intimately tied to the PDF standard. Not only does it derive its imaging model from PDF, it offers applications an easy to use mechanism for creating simple PDFs and drawing many more. You can even add some interaction features to the PDFs you create using Quartz 2D. The resolution independence of PDF graphics make them attractive in printing environments. They may also play an important role in the future as high-resolution monitors and other devices become commonplace. By adopting the PDF metafile capabilities in Quartz 2D, your application will be ready for these advancements today.




Quartz 2D Graphics for Mac OS X Developers
Quartz 2D Graphics for Mac OS X Developers
ISBN: 0321336631
EAN: 2147483647
Year: 2006
Pages: 100

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net