iOS
ComPDFKit PDF SDK
Guides

Extract Image

 

To extract images from a PDF document, use function CPDFDocument::extractImageFromPages:toPath:.

 

Extracting images from a page is time-consuming, and you are advised to perform this operation asynchronously. In addition, you can use CPDFDocument::cancelExtractImage: to cancel the operation.

 

The code below will grab all images from the first page of the given PDF document:

 

NSURL *url = [NSURL fileURLWithPath:@""];
CPDFDocument *document = [[[CPDFDocument alloc] initWithURL:url] autorelease];
​
NSIndexSet *pages = [NSIndexSet indexSetWithIndex:0];
NSString *imagePath = @"";
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
    [document extractImageFromPages:pages toPath:imagePath];
});