Creates a PDF-based graphics context that targets the specified mutable data object.
- iOS 3.2+
- Mac Catalyst 13.0+
- tvOS 9.0+
- watchOS 2.0+
The data object to receive the PDF output data.
A rectangle that specifies the default size and location of PDF pages. (This value is used as the default media box for each new page.) The origin of the rectangle should typically be (0, 0). Specifying an empty rectangle (
CGRect) sets the default page size to 8.5 by 11 inches (612 by 792 points).
A dictionary that specifies additional information to be associated with the PDF file. You can use these keys to specify additional metadata and security information for the PDF, such as the author of the PDF or the password for accessing it. The keys in this dictionary are the same keys you pass to the
CGPDFContextfunction and are described in the Auxiliary Dictionary Keys section of CGPDFContext. The dictionary is retained by the new context, so on return you may safely release it.
nilif you do not want to associate any additional information with the PDF document.
After creating the graphics context, this function makes it the current drawing context. Any subsequent drawing commands are therefore captured and turned into PDF data. When you are done drawing, you must call the
UIGraphics function to close the PDF graphics context.
You can use all of the same drawing routines that you would normally use to draw the contents of your application. The graphics context converts all drawing commands into PDF drawing commands automatically. However, before you issue any drawing commands to a PDF context, you must start a new page by calling the
UIGraphics function. You can also use these functions to define additional pages later.
After creating it, you can get the PDF context using the