---
title: "pdfData(actions:)"
framework: uikit
role: symbol
role_heading: Instance Method
path: "uikit/uigraphicspdfrenderer/pdfdata(actions:)"
---

# pdfData(actions:)

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

## Declaration

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

## Parameters

- `actions`: A doc://com.apple.uikit/documentation/UIKit/UIGraphicsPDFRenderer/DrawingActions block that, when invoked by the renderer, executes a set of drawing instructions to create the output PDF.

## Return Value

Return Value A Data object that contains the encoded PDF.

## Discussion

Discussion You provide a set of drawing instructions as the block argument to this method, and the method returns the resulting PDF encoded in a Data object. You can call this method repeatedly to create multiple PDFs, each of which has identical dimensions and format.

## See Also

### Managing the PDF data

- [writePDF(to:withActions:)](uikit/uigraphicspdfrenderer/writepdf(to:withactions:).md)
- [UIGraphicsPDFRenderer.DrawingActions](uikit/uigraphicspdfrenderer/drawingactions.md)
