All the drawing commands can be converted into PDF by the AppKit framework. The PDF data can be sent to a printer or to a file. Note that a PDF will always look as good as possible on any device, because it is resolution independent.
You have already created a view that knows how to generate PDF data to describe how it is supposed to look. Getting the PDF data into a file is really quite easy. NSView has the following method:
func dataWithPDFInsideRect(rect: NSRect) -> NSData
This method creates a data object and then calls drawRect(_:). The drawing commands that would usually go to the screen instead go into the data object. Once you have ...