Instance Method


Creates a PDF by following a set of drawing instructions and saves it to a specified URL.


func writePDF(to url: URL, withActions actions: (UIGraphicsPDFRendererContext) -> Void) throws



The URL where the complete PDF file is saved.


A UIGraphicsPDFRenderer.DrawingActions closure that, when invoked by the renderer, executes a set of drawing instructions to create the output PDF.


A pointer to an NSError object that is populated if there is a problem saving the completed PDF file.

Return Value

No return value in Swift.


You provide a set of drawing instructions as the block argument to this method, and the method attempts to write the resulting PDF to the supplied URL.

You can call this method repeatedly to create multiple PDFs, each of which has identical dimensions and format.

See Also

Managing the PDF Data

func pdfData(actions: (UIGraphicsPDFRendererContext) -> Void) -> Data

Creates a PDF by following a set of drawing instructions and returns it as a data object.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software