是否有将PDF文档(或至少PDF文档的第一页)转换为图像的原生方式?
答案 0 :(得分:5)
使用ImageIO.framework,您可以执行以下操作:
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);