• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
CGImageDestinationFinalize image destination does not have enough images ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

CGImageDestinationFinalize image destination does not have enough images ?


  • Subject: CGImageDestinationFinalize image destination does not have enough images ?
  • From: DairyKnight <email@hidden>
  • Date: Tue, 1 Sep 2009 18:26:54 +0800

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 (email@hidden)

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:

This email sent to email@hidden

  • Follow-Ups:
    • Re: CGImageDestinationFinalize image destination does not have enough images ?
      • From: Ken Ferry <email@hidden>
  • Prev by Date: [iPhone 3.0] Flipping view doesn't play nice with Navigation and Tab bars.
  • Next by Date: Re: [iPhone 3.0] Flipping view doesn't play nice with Navigation and Tab bars.
  • Previous by thread: Re: [iPhone 3.0] Flipping view doesn't play nice with Navigation and Tab bars.
  • Next by thread: Re: CGImageDestinationFinalize image destination does not have enough images ?
  • Index(es):
    • Date
    • Thread