Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 02-03-2010, 02:30 PM   #1 (permalink)
Jume
Registered Member
 
Jume's Avatar
 
Join Date: Jul 2008
Location: Slovenia, EU
Posts: 264
Jume is on a distinguished road
Send a message via Skype™ to Jume
Default Save PDF pages as image files

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

Last edited by Jume; 02-03-2010 at 03:30 PM.
Jume is offline   Reply With Quote
 

» Advertisements
» Stats
Members: 175,445
Threads: 94,031
Posts: 402,603
Top Poster: BrianSlick (7,978)
Welcome to our newest member, Adamz3us
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 09:53 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.