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.
Resizing-up the whole image could be a solution, but I don't think this is the 
best one.

So is it possible to print directly a PDF based CGContextRef ?

Here's my IBAction to create the PDF:

-(IBAction)exportActiveGraphsToPDF:(id)sender
NSSavePanel *pdfSavingDialog = [NSSavePanel savePanel];
[pdfSavingDialog setMessage:@"Export as PDF"];
    
NSArray *pdfType = [[NSArray alloc] initWithObjects:@"pdf", nil];
[pdfSavingDialog setAllowedFileTypes:pdfType];
[pdfType release];
    
if ( [pdfSavingDialog runModal] == NSOKButton ) {
        
    NSMutableData *pdfData = [[NSMutableData alloc] init];
    CGDataConsumerRef dataConsumer = 
CGDataConsumerCreateWithCFData((CFMutableDataRef)pdfData);
        
    CGRect pdfMediaBox = NSRectToCGRect([allGraphsView bounds]);
        
    CGContextRef pdfContext = CGPDFContextCreate(dataConsumer, &pdfMediaBox, 
NULL);
    CGContextBeginPage(pdfContext, &pdfMediaBox);
    
    // call renderGraphsInContext to draw the coreplot graphs in the given 
CGContextRef   
    [self renderGraphsInContext:pdfContext];
        
        CGContextEndPage(pdfContext);   
        CGPDFContextClose(pdfContext);
        
        [pdfData writeToURL:[pdfSavingDialog URL] atomically:NO];
        
        CGContextRelease(pdfContext);
        CGDataConsumerRelease(dataConsumer);
        [pdfData release];
    }
}    

(1)
http://code.google.com/p/core-plot/

Any help is greatly appreciated.

Cheers,

Gilles

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to