<!--
{
  "documentType" : "article",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/nsview-printing",
  "metadataVersion" : "0.1.0",
  "role" : "collectionGroup",
  "title" : "Printing"
}
-->

# Printing

Create a printable version of your view’s content and handle pagination and printer-related behaviors.

## Topics

### Printing the View’s Content

[`func printView(Any?)`](/documentation/AppKit/NSView/printView(_:))

This action method opens the Print panel, and if the user chooses an option other than canceling, prints the view and all its subviews to the device specified in the Print panel.

[`func beginPage(in: NSRect, atPlacement: NSPoint)`](/documentation/AppKit/NSView/beginPage(in:atPlacement:))

Called at the beginning of each page, this method sets up the coordinate system so that a region inside the view’s bounds is translated to a specified location.

[`func dataWithEPS(inside: NSRect) -> Data`](/documentation/AppKit/NSView/dataWithEPS(inside:))

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

[`func dataWithPDF(inside: NSRect) -> Data`](/documentation/AppKit/NSView/dataWithPDF(inside:))

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

[`var printJobTitle: String`](/documentation/AppKit/NSView/printJobTitle)

The view’s print job title.

[`var pageHeader: NSAttributedString`](/documentation/AppKit/NSView/pageHeader)

A default header string that includes the print job title and date.

[`var pageFooter: NSAttributedString`](/documentation/AppKit/NSView/pageFooter)

A default footer string that includes the current page number and page count.

[`func writeEPS(inside: NSRect, to: NSPasteboard)`](/documentation/AppKit/NSView/writeEPS(inside:to:))

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

[`func writePDF(inside: NSRect, to: NSPasteboard)`](/documentation/AppKit/NSView/writePDF(inside:to:))

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

[`func drawPageBorder(with: NSSize)`](/documentation/AppKit/NSView/drawPageBorder(with:))

Allows applications that use the AppKit pagination facility to draw additional marks on each logical page.

[`func drawSheetBorder(with: NSSize)`](/documentation/AppKit/NSView/drawSheetBorder(with:))

Allows applications that use the AppKit pagination facility to draw additional marks on each printed sheet.

### Handling Pagination

[`var heightAdjustLimit: CGFloat`](/documentation/AppKit/NSView/heightAdjustLimit)

The fraction of the page that can be pushed onto the next page during automatic pagination to prevent items such as lines of text from being divided across pages.

[`var widthAdjustLimit: CGFloat`](/documentation/AppKit/NSView/widthAdjustLimit)

The fraction of the page that can be pushed onto the next page during automatic pagination to prevent items such as small images or text columns from being divided across pages.

[`func adjustPageWidthNew(UnsafeMutablePointer<CGFloat>, left: CGFloat, right: CGFloat, limit: CGFloat)`](/documentation/AppKit/NSView/adjustPageWidthNew(_:left:right:limit:))

Overridden by subclasses to adjust page width during automatic pagination.

[`func adjustPageHeightNew(UnsafeMutablePointer<CGFloat>, top: CGFloat, bottom: CGFloat, limit: CGFloat)`](/documentation/AppKit/NSView/adjustPageHeightNew(_:top:bottom:limit:))

Overridden by subclasses to adjust page height during automatic pagination.

[`func knowsPageRange(NSRangePointer) -> Bool`](/documentation/AppKit/NSView/knowsPageRange(_:))

Returns a Boolean value that indicates whether the view handles page boundaries.

[`func rectForPage(Int) -> NSRect`](/documentation/AppKit/NSView/rectForPage(_:))

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

[`func locationOfPrintRect(NSRect) -> NSPoint`](/documentation/AppKit/NSView/locationOfPrintRect(_:))

Invoked by [`printView(_:)`](/documentation/AppKit/NSView/printView(_:)) to determine the location of the region of the view being printed on the physical page.

### Writing Conforming Rendering Instructions

[`func beginDocument()`](/documentation/AppKit/NSView/beginDocument())

Invoked at the beginning of the printing session, this method sets up the current graphics context.

[`func endDocument()`](/documentation/AppKit/NSView/endDocument())

This method is invoked at the end of the printing session.

[`func endPage()`](/documentation/AppKit/NSView/endPage())

Writes the end of a conforming page.



---

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)