---
title: beginDocument()
framework: appkit
role: symbol
role_heading: Instance Method
path: appkit/nsview/begindocument()
---

# beginDocument()

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

## Declaration

```swift
func beginDocument()
```

## Discussion

Discussion Note that this method may be invoked in a subthread. Override it to configure printing related settings. You should store your settings in the object returned by NSPrintInfo’s shared class method, which is guaranteed to return an instance specific to the thread in which you invoke this method. If you override this method, call the superclass implementation.

## See Also

### Writing Conforming Rendering Instructions

- [endDocument()](appkit/nsview/enddocument().md)
- [endPage()](appkit/nsview/endpage().md)
