Basic Printing
Printing is usually handled by NSView and its subclasses. The code executed to print a view is most often the same code used to draw the view onscreen. When a view receives the –print: message it displays a standard Cocoa Print panel. If the user clicks the Print panel’s Print or Preview buttons, the view’s –drawRect: method is called, much like when the view is requested to draw to the screen. The main difference is that when printing, the current graphics context is a printing context instead of a display context.
When implementing the –drawRect: method of an NSView subclass, it is possible to determine if the view is drawing to the screen or to another device, such as a printer, by calling [[NSGraphicsContext currentContext] ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access