Hi, I'm trying to extract pages from PDF files and save them to jpg. But keep getting the 'doesnt have enough images' error. Anyone knows why?
Thanks. Here's the code: // Opens the pdf file and gets the PdfPage PDFDocument *pdfDoc = [[PDFDocument alloc] initWithURL:[NSURL fileURLWithPath:filename]]; PDFPage *page = [pdfDoc pageAtIndex:1]; NSPDFImageRep *pdfImg = [NSPDFImageRep imageRepWithData:[page dataRepresentation]]; NSSize size; size.width = 1024; size.height = 768; NSImage *img = [[NSImage alloc] initWithSize:size]; [img lockFocus]; // Draw the pdf page in an offscreen NSImage [pdfImg drawInRect:NSMakeRect(0, 0, 1024, 768)]; [img unlockFocus]; [img setCacheMode:NSImageCacheNever]; if (![img isValid]) NSLog(@"img is not valid"); [imgView setImage:img]; // Saves the NSImage to disk.... getting the error NSArray *representations; NSData *bitmapData; representations = [img representations]; bitmapData = [NSBitmapImageRep representationOfImageRepsInArray :representations usingType:NSJPEGFileType properties:nil]; [bitmapData writeToFile:@"/Users/Tom/test.jpeg" atomically:YES]; _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com