Adobe's Portable Document Format (PDF) is the file format that Adobe created to facilitate the distribution of multi-page documents. As seen in Chapter 2, "From QuickDraw to Quartz 2D," Quartz 2D bases its imaging model on the graphics systems of PostScript and PDF. In the early days of PDF, a program called the Distiller would execute PostScript code and collect all the drawing commands into a PDF file. When a PDF viewer played back those commands, the user would see all of the drawing that would have been done by the original PostScript program without having to reinterpret that program itself. Quartz 2D uses PDF as its metafile format. A metafile captures a series of drawing commands that create an image, rather than the image itself. The PDF files that Quartz generates record the paths, images, and text that an application draws into a PDF graphics context. This preserves the color fidelity, resolution independence, and other hallmark features associated with Quartz 2D graphics. Not every PDF file is a Quartz 2D metafile, but Quartz 2D can draw the contents of PDF files that are not metafiles. This is a powerful feature that allows many applications on the system to enjoy the benefits of PDF's vector graphics with the investment of a few lines of code. The metafiles generated by Quartz 2D are PDF files, but Quartz is not a generalized tool for writing PDF files. Core Graphics handles many of the graphics and interactive features that are defined in the PDF spec. For example, the PDF specification includes shadings that you cannot create through Quartz 2D. PDF files also can contain interactive forms. Quartz 2D might display the contents of the forms but does not offer any features for creating those forms.
This chapter examines the facilities in Quartz 2D for creating new PDF documents and drawing existing documents as well as some of the information that Quartz 2D allows you to extract from PDF files. |