<!--
{
  "availability" : [
    "macOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSWindow/dataWithPDF(inside:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSWindow(im)dataWithPDFInsideRect:"
  },
  "title" : "dataWithPDF(inside:)"
}
-->

# dataWithPDF(inside:)

Returns PDF data that draws the region of the window within a given rectangle.

```
func dataWithPDF(inside rect: NSRect) -> Data
```

## Parameters

`rect`

A rectangle (expressed in the window’s coordinate system) that identifies the region to be expressed as PDF data.

## Return Value

The region in the window (identified by `rect`) as PDF data.

## Discussion

This data can be placed on a pasteboard, written to a file, or used to create an `NSImage` object.

## See Also

[`writePDF(inside:to:)`](/documentation/AppKit/NSView/writePDF(inside:to:))

Writes PDF data that draws the region of the view within a specified rectangle onto a pasteboard.

[`dataWithPDF(inside:)`](/documentation/AppKit/NSView/dataWithPDF(inside:))

Returns PDF data that draws the region of the view within a specified rectangle.



---

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)