• 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
Re: CGImageDestinationFinalize image destination does not have enough images ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CGImageDestinationFinalize image destination does not have enough images ?


  • Subject: Re: CGImageDestinationFinalize image destination does not have enough images ?
  • From: Ken Ferry <email@hidden>
  • Date: Tue, 1 Sep 2009 17:08:29 -0700

Hi,
-[NSBitmapImageRep representationOfImageRepsInArray:usingType:properties:]
requires an array of NSBitmapImageReps, not arbitrary NSImageReps.

-Ken
On Tue, Sep 1, 2009 at 3:26 AM, DairyKnight <email@hidden> wrote:

> 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
>
_______________________________________________

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

References: 
 >CGImageDestinationFinalize image destination does not have enough images ? (From: DairyKnight <email@hidden>)

  • Prev by Date: Re: contextual menu plugin example in cocoa
  • Next by Date: Re: contextual menu plugin example in cocoa
  • Previous by thread: CGImageDestinationFinalize image destination does not have enough images ?
  • Next by thread: Re: How To Unbind
  • Index(es):
    • Date
    • Thread