problem generating PDF using quartz
problem generating PDF using quartz
- Subject: problem generating PDF using quartz
- From: Victor Bovio <email@hidden>
- Date: Fri, 7 Mar 2008 12:58:08 -0600
Hi,
I'm trying to save a test PDF from scratch using the following code:
NSString *path = @"~/Desktop/test.pdf";
NSString *fullPath = [path stringByExpandingTildeInPath];
CFStringRef str =
CFStringCreateWithCString(kCFAllocatorDefault, [fullPath cString],
kCFStringEncodingMacRoman);
CFURLRef url = CFURLCreateWithString(kCFAllocatorDefault,
str, NULL);
CGDataConsumerRef consumer = CGDataConsumerCreateWithURL(url);
CGRect mediaBox = CGRectMake(0, 0, 100, 100);
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
float rgba[] = { 1.0, 0.5, 0.0, 1.0 };
CGColorRef color = CGColorCreate(colorSpace, rgba);
// CGContextRef pdfContext = CGPDFContextCreateWithURL(url,
&mediaBox, NULL);
CGContextRef pdfContext = CGPDFContextCreate(consumer,
&mediaBox, NULL);
CGContextBeginPage(pdfContext, &mediaBox);
CGContextSaveGState(pdfContext);
CGContextClipToRect(pdfContext, mediaBox);
CGContextSetFillColorWithColor(pdfContext, color);
CGContextFillRect(pdfContext, mediaBox);
CGContextRestoreGState(pdfContext);
CGContextEndPage(pdfContext);
CGContextRelease(pdfContext);
CGDataConsumerRelease(consumer);
CGColorRelease(color);
CGColorSpaceRelease(colorSpace);
but I get this error when trying it:
"<Error>: CGDataConsumer(url_close): write failed: -15."
any ideas ???
Thanks.
_______________________________________________
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