• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
problem generating PDF using quartz
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Prev by Date: Re: MEETING: Chicago CocoaHeads/CAWUG - iPhone SDK (duh! what else this month)
  • Next by Date: Re: NSTextView changes font
  • Previous by thread: Re: NSCollectionView and default selections ...
  • Next by thread: Re: Binding Error (accessing value for key) - but works with debugging on (SOLVED)
  • Index(es):
    • Date
    • Thread