---
title: "writePDF(to:withActions:)"
framework: uikit
role: symbol
role_heading: Instance Method
path: "uikit/uigraphicspdfrenderer/writepdf(to:withactions:)"
---

# writePDF(to:withActions:)

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

## Declaration

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

## Parameters

- `url`: The URL where the complete PDF file is saved.
- `actions`: A doc://com.apple.uikit/documentation/UIKit/UIGraphicsPDFRenderer/DrawingActions closure that, when invoked by the renderer, executes a set of drawing instructions to create the output PDF.

## Discussion

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

- [pdfData(actions:)](uikit/uigraphicspdfrenderer/pdfdata(actions:).md)
- [UIGraphicsPDFRenderer.DrawingActions](uikit/uigraphicspdfrenderer/drawingactions.md)
