I'm reading pdf's in a view and trying to capture screenshots of pdf pages. UIGraphicsGetImageFromCurrentImageContext() doesn't work. any solutions?
A:
That only works when the current image context is relevant, for instance if you are calling this within the drawRect method of a UIView then you have the context relating to the view.
Instead you need to create a new graphics context and render the view into it...
UIGraphicsBeginImageContext(view.size);
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGRect area = CGRectMake(0, 0, view.size.width, view.size.height);
CGContextDrawImage(ctx, area, view.layer.CGImage);
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
This is from memory so I hope this is correct but you get the idea....
Simon Lee
2010-08-13 13:54:02
Got it. Thanku :)
preeti
2010-08-15 06:04:22