A type of CGContext for drawing PDF content.


The CGPDFContext functions operate only on Core Graphics PDF graphics contexts created using the functions init(consumer:mediaBox:_:) or init(_:mediaBox:_:).

When you draw to the PDF context using CGContext functions the drawing operations are recorded in PDF format. The PDF commands that represent the drawing are written to the destination specified when you create the PDF graphics context.


Beginning and Ending Pages

func beginPDFPage(CFDictionary?)

Begins a new page in a PDF graphics context.

func endPDFPage()

Ends the current page in the PDF graphics context.

Working with Destinations

func addDestination(CFString, at: CGPoint)

Sets a destination to jump to when a point in the current page of a PDF graphics context is clicked.

func setDestination(CFString, for: CGRect)

Sets a destination to jump to when a rectangle in the current PDF page is clicked.

func setURL(CFURL, for: CGRect)

Sets the URL associated with a rectangle in a PDF graphics context.

Working with Metadata

func addDocumentMetadata(CFData?)

Associates custom metadata with the PDF document.

Closing a PDF Context

func closePDF()

Closes a PDF document.


Auxiliary Dictionary Keys

Keys for the auxiliary info dictionary you specify when creating a PDF context.

See Also

Related Documentation