---
title: "createPDF(configuration:completionHandler:)"
framework: webkit
role: symbol
role_heading: Instance Method
path: "webkit/wkwebview/createpdf(configuration:completionhandler:)"
---

# createPDF(configuration:completionHandler:)

Generates PDF data from the web view’s contents asynchronously.

## Declaration

```swift
@MainActor @preconcurrency func createPDF(configuration: WKPDFConfiguration = .init(), completionHandler: @escaping @MainActor @Sendable (Result<Data, any Error>) -> Void)
```

## Parameters

- `configuration`: The object that specifies the portion of the web view to capture as PDF data.
- `completionHandler`: The completion handler to call when the data is ready. This block has no return value and takes the following parameters:

## See Also

### Capturing the web view’s content

- [takeSnapshot(with:completionHandler:)](webkit/wkwebview/takesnapshot(with:completionhandler:).md)
- [pdf(configuration:)](webkit/wkwebview/pdf(configuration:).md)
- [createWebArchiveData(completionHandler:)](webkit/wkwebview/createwebarchivedata(completionhandler:).md)
- [printOperation(with:)](webkit/wkwebview/printoperation(with:).md)
- [WKSnapshotConfiguration](webkit/wksnapshotconfiguration.md)
- [WKPDFConfiguration](webkit/wkpdfconfiguration.md)
