Does anybody know how to take the current contents of a UIWebView and save them into a pdf file?
Using this tutorial as a starting point, I took out everything between CGContextBeginPage and CGContextEndPage.
I first tried
Code:
// webView is my passed in UIWebView *
[webView.layer drawInContext:pdfContext];
The documentation says that UIView's have a layer property of type CALayer *, and CALayer has a drawInContext method. Yet I get a warning that there is no drawInContext method here, and nothing happens when I run it.
Next I tried:
Code:
UIGraphicsPushContext(pdfContext);
[webView setNeedsDisplay];
UIGraphicsPopContext();
Which I think may be closer to the right track, but that still generates an empty pdf file.
Any help would be appreciated.