I have a web view that I am trying to print and when i load a webpage that is long (more than a page) it prints out all black. I cannot use the renderInContext method because it crashes the app because of high memory issues when i try to print a page. I am using a dymo receipt printer.
Here is the code that i have
+ (UIImage*)viewToImage:(UIView*)theView
{
UIImage *image = nil;
// Save current bounds so we can reset them laster
CGRect tmpFrame = theView.frame;
CGRect tmpBounds = theView.bounds;
// Adjust the bounds of the webview so we can take a screen shot of the entire view, even if its scrolled off screen.
CGRect aFrame = theView.bounds;
aFrame.size.width = theView.frame.size.width;
aFrame.size.height = theView.frame.size.height;
theView.frame = aFrame;
aFrame.size.height = [theView sizeThatFits:[[UIScreen mainScreen] bounds].size].height;
theView.frame = aFrame;
UIGraphicsBeginImageContextWithOptions(theView.bounds.size, NO, 1.8);
[theView drawViewHierarchyInRect:theView.bounds afterScreenUpdates:YES];
// crashes the app [self.layer renderInContext:UIGraphicsGetCurrentContext()];
image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}