How to save a NSTextView in a PDF file ?

I want the user of my be able to save a text view as a PDF on disk…
NSView of which NSTextView is a subclass, has the - (NSData *)dataWithPDFInsideRect:(NSRect)aRect instance method.
Of course the problem is a little bit more complicated if you want that the resulting PDF file respects your page setup setting and automatically flows the text into several page.
One of the simplest solution (conceptually) is to use the
Save As PDF mechanism of the printing engine. Other solutions may be to use PDF frameworks and libraries (some are OpenSource) to control more precisely the output.