In my cocoa application , I need to save each page of the pdf as a jpg .. How can i proceeed using Objective C
Using pure Objective-C (Cocoa and PDF Kit), iterate on the pages of your PDF document, and for each one, create an NSImage whose size is that of the media box of the page, lock focus on it, tell the page to draw, create an NSBitmapImageRep with the focused view (the image), unlock focus on the image, then ask the bitmap image rep for the JPEG data and write that data to the file. (This solution sucks; don't use it.)
Another way is Core Graphics and ImageIO. Create a bitmap context matching the media box and color space of the document, then for each page, create an image destination for the JPEG file, get the page from the document, draw the page in the context, create a CGImage from the context, clear the context using CGContextClearRect
, add the image the destination, and finalize the destination.