<!--
{
  "availability" : [
    "iOS: 10.0.0 -",
    "iPadOS: 10.0.0 -",
    "macCatalyst: 13.1.0 -",
    "tvOS: 10.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UIGraphicsPDFRenderer/writePDF(to:withActions:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UIGraphicsPDFRenderer(im)writePDFToURL:withActions:error:"
  },
  "title" : "writePDF(to:withActions:)"
}
-->

# writePDF(to:withActions:)

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

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

## Parameters

`url`

The URL where the complete PDF file is saved.

`actions`

A [`UIGraphicsPDFRenderer.DrawingActions`](/documentation/UIKit/UIGraphicsPDFRenderer/DrawingActions) closure that, when invoked by the renderer, executes a set of drawing instructions to create the output PDF.

## 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.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)