Is there a native way to convert a PDF document (or atleast the first page of a PDF document) into an image?
Asked
Active
Viewed 1,440 times
1 Answers
5
Using ImageIO.framework you can do something like this :
CGImageSourceRef src = CGImageSourceCreateWithURL(PDF_URL, NULL);
NSDictionary* options = [NSDictionary dictionaryWithObject:(id)[NSNumber numberWithInt:500] forKey:(id)kCGImageSourceThumbnailMaxPixelSize];
CGImageRef firstPage = CGImageSourceCreateImageAtIndex(src, 0, options); // 0 first page of the pdf
CFRelease(src);
UIImage* img = [UIImage imageWithCGImage:firstPage];
CGImageRelease(firstPage);

Nyx0uf
- 4,609
- 1
- 25
- 26
-
Gives a nil UIImage for me – jjxtra May 18 '14 at 19:47