Search code examples
quartz-composer

The right way to print a QCView


I have put much time and effort into drawing certain 3d plots and surfaces using a Quartz Composition. Everything looks wonderful in my (Cocoa) application's QCView. However, in order to print, I am taking a snapshot of the QCView to generate an NSImage, and putting that in an NSView for my print options screen. However, lines and colors in the snapshot look horrendously aliased. Is there some other way to either directly print from my QCView, or to bypass/override taking a snapshot so that the NSImage looks as good as what's in my QCView? QCView inherits from NSView, but the built-in print method doesn't seem to work.

Thanks!


Solution

  • Thanks smokris, but I found that the way to do this is to take a CGImage snapshot. I thought I'd be able to put this snapshot in an IKImageView, which preserves anti-aliasing, but IKImageView suffers from the same issue QCView, in that when print is called you get nothing in your print window.

    So, the method that finally worked is to create pdf data from the CGImage snapshot using a CGPDFContext, load up an NSImageView with an NSImage generated from this pdf data, and when this goes to a print window all anti-aliasing is preserved! Very roundabout, but works like charm!