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

# rectForPage(_:)

Implemented by subclasses to determine the portion of the view to be printed for the specified page number.

```
func rectForPage(_ page: Int) -> NSRect
```

## Parameters

`page`

An integer indicating a page number. Page numbers are one-based—that is pages run from one to *N*.

## Return Value

A rectangle defining the region of the view to be printed for `pageNumber`. This method returns `NSZeroRect` if `pageNumber` is outside the view’s bounds.

## Discussion

If the view responded <doc://com.apple.documentation/documentation/Swift/true> to an earlier [`knowsPageRange(_:)`](/documentation/AppKit/NSView/knowsPageRange(_:)) message, this method is invoked for each page it specified in the out parameters of that message. The view is later made to display this rectangle in order to generate the image for this page.

If an `NSView` object responds <doc://com.apple.documentation/documentation/Swift/false> to [`knowsPageRange(_:)`](/documentation/AppKit/NSView/knowsPageRange(_:)), this method isn’t invoked by the printing mechanism.

---

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)