Question

I'm working with an NSImage which comes from a PDF. When I initially create the image, it has only one NSImageRep and that is NSPDFImageRep. This is good. I can work with it. I can find out how many pages it has, and go to a specified page, and draw it, etc.

The problem is that as soon as I turn my back, it gets turned into a NSCachedImageRep, which doesn't seem to have multiple pages. Now, if I keep the PDFImageRep in a separate variable, it is kept track of, but it isn't associated with the image anymore, so when I draw the image, it's still on the same page.

What am I missing?

thanks.

Was it helpful?

Solution

You need to call [image setDataRetained:YES] on the image, so that your original PDF data is kept around, otherwise it will be cached to a bitmap.

If you're still having problems you could turn off caching altogether by using [image setCacheMode:NSImageCacheNever].

OTHER TIPS

Try it on 10.6. The problem has probably evaporated.

Please see the AppKit release notes for details of the NSImage changes.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top