在我的 cocoa 应用程序中,我需要将 pdf 的每一页保存为 jpg ..我如何继续使用 Objective C
Using pure Objective-C (Cocoa and PDF Kit http://developer.apple.com/documentation/GraphicsImaging/Reference/PDFKit_Ref/), 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.)
另一种方式是Core Graphics和ImageIO。创建与文档的媒体框和颜色空间匹配的位图上下文,然后为每个页面创建 JPEG 文件的图像目标,从文档获取页面,在上下文中绘制页面,从上下文创建 CGImage,使用清除上下文CGContextClearRect
,将图像添加到目的地,并最终确定目的地。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)