Re: Convert PDF CGContextRef to NSView for hi-res printing
Re: Convert PDF CGContextRef to NSView for hi-res printing
- Subject: Re: Convert PDF CGContextRef to NSView for hi-res printing
- From: Graham Cox <email@hidden>
- Date: Tue, 06 Mar 2012 09:12:28 +1100
On 06/03/2012, at 7:13 AM, Gilles Celli wrote:
> Hi,
>
> I'm stuck on a problem on how to print high resolution graphs on Mac OS X, by using the wonderful CorePlot (1) framework.
> I've asked on the Coreplot mailing list but no answer...maybe it's too obvious that I don't see the tree in the forest:
>
> My method produces a CGContextRef (with CGPDFContextCreate) which then writes the drawing / plotting as a PDF.
> This works great: The written PDF file doesn't have any jaggies since it is vector based.
>
> However if I want print the graphs via the Printer Panel, I need first to create a bitmap-based NSImageView as far as I understand,
> so the prints never seem to be vector based, there will always be jaggies in the plots and text.
Your understanding is definitely wrong.
You need a view to cooperate with the print subsystem, but it doesn't have to be NSImageView, and usually is not. Ultimately, the print system ends up calling the view's -dataWithPDFInsideRect: method. If you override that method to return your PDF data, you're done. Of course there will be other things to consider, such as pagination, so that approach might be too simplistic, but might give you a starting point. Printing is entirely built around PDF, so there is no reason to accept bitmaps, jaggies or any other artefact of rasterization.
--Graham
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden