Chapter 14. Working with PDF


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.

Quartz 2D does provide some routines that allow you to access the structure and content of a PDF file in its raw form. If you need very low-level access to the contents of a PDF file, you can use the CGPDFScanner API to get at the guts of PDF files. To scan the PDF file, your application registers a series of callbacks that you want Quartz 2D to invoke when it encounters certain PDF operators in a PDF stream. You can then call on Quartz to parse the PDF stream and invoke your callbacks using the CGPDFScanner API. If you want more information on using this mechanism to explore the structure and contents of PDF files, please read the "Parsing PDF Content" chapter of Apple's Quartz 2D Programming Guide.

http://developer.apple.com/documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/index.html

Mac OS X includes an additional technology know as PDFKit that allows you to access features of PDF that Quartz 2D does not. Through the PDF kit your application can access and display PDF file annotations and work with the outlines embedded in PDF documents. For more information on PDFKit you can visit the Apple Developer Connection web site.

http://developer.apple.com/documentation/GraphicsImaging/Conceptual/PDFKitGuide/index.html


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.




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