---
title: "takeSnapshot(with:completionHandler:)"
framework: webkit
role: symbol
role_heading: Instance Method
path: "webkit/wkwebview/takesnapshot(with:completionhandler:)"
---

# takeSnapshot(with:completionHandler:)

Generates a platform-native image from the web view’s contents asynchronously.

## Declaration

```swift
func takeSnapshot(with snapshotConfiguration: WKSnapshotConfiguration?, completionHandler: @escaping @MainActor @Sendable (UIImage?, (any Error)?) -> Void)
```

```swift
func takeSnapshot(configuration snapshotConfiguration: WKSnapshotConfiguration?) async throws -> UIImage
```

```swift
func takeSnapshot(with snapshotConfiguration: WKSnapshotConfiguration?, completionHandler: @escaping @MainActor @Sendable (NSImage?, (any Error)?) -> Void)
```

```swift
func takeSnapshot(configuration snapshotConfiguration: WKSnapshotConfiguration?) async throws -> NSImage
```

## Parameters

- `snapshotConfiguration`: The object that specifies the portion of the web view to capture, and other capture-related behaviors.
- `completionHandler`: The completion handler to call when the image is ready. This block has no return value and takes the following parameters:

## See Also

### Capturing the web view’s content

- [createPDF(configuration:completionHandler:)](webkit/wkwebview/createpdf(configuration: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)
