0

i want to convert my webpage(displayed in UIWebView) contents in pdf file.

which can be stored at perticular directory (document dir/any user defined dir).

So later on it can be viewable to user either internet connection not available.

is there any possibilities to perform this functionality.

how can i do this...

Thanking you in advance...

MohammedYakub M.
  • 2,893
  • 5
  • 31
  • 42

1 Answers1

2

An image might be your best option. See Take snapshot of view / WebView programmatically

To get the image, you'll want to use:

UIGraphicsBeginImageContext(self.bounds.size);

[theView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

Then, to save to the Photos Library:

UIImageWriteToSavedPhotosAlbum(viewImage,nil,NULL,NULL);
Community
  • 1
  • 1
psychotik
  • 38,153
  • 34
  • 100
  • 135
  • is this will capture all the content even the scrollable content out side of the screen(means content below the viewable area)... ? or only snapshot(means only viewable area) ? – MohammedYakub M. Apr 16 '10 at 05:50
  • you control it based on the value to pass to the UIGraphicsBeingImageContext function. See http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIKitFunctionReference/Reference/reference.html#//apple_ref/c/func/UIGraphicsBeginImageContext – psychotik Apr 16 '10 at 05:58
  • thanks for your responce psychotik, but i want to convert it in pdf...is there any way ? or can we open pdf from website in UIWebView ? or not ? if yes then can we save it to the local disk space in iPhone ? please ans all my questions because i am little bit confuse about it... – MohammedYakub M. Apr 16 '10 at 07:21
  • To answer your question about opening a PDF in a UIWebView, it is possible to do this. I recommend having a look at this question: http://stackoverflow.com/questions/2832245/iphone-can-we-open-pdf-file-using-uiwebview. – Bart Jacobs May 28 '12 at 05:34