<!--
{
  "availability" : [
    "iOS: 14.0.0 -",
    "iPadOS: 14.0.0 -",
    "macCatalyst: -",
    "macOS: 11.0.0 -",
    "visionOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "WebKit",
  "identifier" : "/documentation/WebKit/WKWebView/createPDF(configuration:completionHandler:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "WebKit"
    ],
    "preciseIdentifier" : "s:So9WKWebViewC6WebKitE9createPDF13configuration17completionHandlerySo18WKPDFConfigurationC_ys6ResultOy10Foundation4DataVs5Error_pGctF"
  },
  "title" : "createPDF(configuration:completionHandler:)"
}
-->

# createPDF(configuration:completionHandler:)

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

```
@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:

- pdfDocumentData: A data object that contains the PDF data to use for rendering the contents of the web view.
- error: An error object if a problem occurred, or `nil` on success.

## Discussion

---

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)