Instance Method

writePDFToURL:withActions:error:

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

Declaration

- (BOOL)writePDFToURL:(NSURL *)url withActions:(UIGraphicsPDFDrawingActions)actions error:(NSError * _Nullable *)error;

Parameters

url

The URL where the complete PDF file is saved.

actions

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

error

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

Return Value

YES if the PDF has been saved successfully, NO otherwise.

Discussion

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

- PDFDataWithActions:

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