Getting CGImageRef from PDFDocument

I have a PDFDocument (consisting of PDFPages of the course) and I need a CGImageRef to enter in IKImageView.

Currently, I get the datarepresentation from PDFPage, put it in NSImage, then get the NSImage TIFF representation, put it in a CGImageSource, and then fetch the CGImage from the source.

It seems easy to go through two steps of NSData ...

However, when I try to put the PDF data directly into the CGImageSource, even if this APPEARS works, when I get the CGImage, it is always NULL. is there anything concrete i have to do to get this to work?

+3
source share
3 answers

Snow Leopard -[NSImage CGImageForProposedRect:context:hints:]. CGBitmapContext CGBitmapContextCreateImage.

+1

CreatePDFPageImage CGPDFAdditions. , , .

+1

Try feeding data for a PDF document (as opposed to a single page) to CGImageSource. Images from the source must match the pages in the document.

0
source

Source: https://habr.com/ru/post/1757838/


All Articles