Hi,
I am trying to save each PDF's page as an image file on my mac. I've come up with the Quartz solution, but it's giving me problems.... Here's my code:
Code:
NSData *pdfData = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://localhost/uniki/unicenter/static/images/cluster/test.pdf"]];
CFDataRef pdfDataRef = (CFDataRef)pdfData;
CGImageSourceRef imgSoureRef = CGImageSourceCreateWithData(pdfDataRef, NULL);
NSLog(@"Number of sources: %d", GImageSourceGetCount(imgSoureRef));
CGImageRef imgRef = NULL;
CFDictionaryRef dictP = NULL;
if (imgSoureRef) {
imgRef = CGImageSourceCreateImageAtIndex(imgSoureRef, 0, NULL);
dictP = CGImageSourceCopyPropertiesAtIndex(imgSoureRef, 0, NULL);
}
NSURL *outPath = [NSURL fileURLWithPath:@"/Users/mac/Desktop/page01.jpg"];
CGImageDestinationRef dest = CGImageDestinationCreateWithURL((CFURLRef)outPath, (CFStringRef)@"public.jpeg" , 1, NULL);
CGImageDestinationAddImage(dest, imgRef, dictP);
CGImageDestinationFinalize(dest);
This are the errors that I'm getting. I tried google on this error but without any success. I really don't understand what are these errors trying to say to me... any help?
2010-02-03 19:29:11.331 UNILoader[6716:a0f] Number of sources: 4
Wed Feb 3 19:29:11 Macintosh-96.local UNILoader[6716] <Error>: CGImageDestinationAddImage image parameter is nil
Wed Feb 3 19:29:11 Macintosh-96.local UNILoader[6716] <Error>: CGImageDestinationFinalize image destination does not have enough images