---
title: "rectForPage(_:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nsview/rectforpage(_:)"
---

# rectForPage(_:)

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

## Declaration

```swift
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

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

Discussion If the view responded true to an earlier 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 false to knowsPageRange(_:), this method isn’t invoked by the printing mechanism.

## See Also

### Handling Pagination

- [heightAdjustLimit](appkit/nsview/heightadjustlimit.md)
- [widthAdjustLimit](appkit/nsview/widthadjustlimit.md)
- [adjustPageWidthNew(_:left:right:limit:)](appkit/nsview/adjustpagewidthnew(_:left:right:limit:).md)
- [adjustPageHeightNew(_:top:bottom:limit:)](appkit/nsview/adjustpageheightnew(_:top:bottom:limit:).md)
- [knowsPageRange(_:)](appkit/nsview/knowspagerange(_:).md)
- [locationOfPrintRect(_:)](appkit/nsview/locationofprintrect(_:).md)
