[ zwView lockFocus ]; // zwView es un objeto que hereda la clase NSView
NSImage * image = [[ NSImage alloc ] initWithData : [ zwView dataWithPDFInsideRect : [ zwView límites ]]];
[ zwView unlockFocus ];
[ Enfoque de bloqueo de imagen ];
// Primero configure la siguiente instancia
NSBitmapImageRep * bits = [[ NSBitmapImageRep alloc ] initWithFocusedViewRect : [ zwView frame ]];
[imagen desbloquearFocus ];
// Configura las propiedades de los accesorios que se usarán más adelante
NSDictionary * imageProps = [ NSDictionary dictionaryWithObject : [ NSNumber numberWithBool : 0 ] forKey : NSImageCompressionFactor ];
// Luego convierta a NSData para guardar en archivo
NSData * imageData = [bits representacionesUsingType : NSPNGFileType propiedades : imageProps];
// almacenar configurado después de la ruta del archivo para aceptar el
[imageData writeToFile : [[[ NSString alloc ] initWithFormat : @ "~ / Documents / test% d.jpg" , 1 ] stringByExpandingTildeInPath ] atómicamente : YES ]; // La ruta del archivo guardado debe ser absoluta, no relativa