Search code examples
objective-cnsviewpdfpage

PDFPage initWithImage: strange behavior


I can't understand the difference. It seams to be the same but is not!

Does enybody know why?

// Working:
PDFPage *imagePDFPage = [[PDFPage alloc] initWithImage:
[[NSImage alloc]initWithContentsOfFile:imagePath]];


// NOT Working:
NSImage *image = [[NSImage alloc]initWithContentsOfFile:imagePath];                           
PDFPage *imagePDFPage = [[PDFPage alloc] initWithImage:image];

Solution

  • Here's the solution:

    NSImage *image = [[NSImage alloc]initWithContentsOfFile:imagePath]; 
    PDFPage *imagePDFPage = [[PDFPage alloc] initWithImage:(CIImage *) image];