Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 06-24-2009, 05:07 AM   #1 (permalink)
Registered Member
 
Join Date: Jun 2009
Posts: 18
Question Save contents of a UIWebView to a pdf file

Hello,

Is there a way to save the contents of UIWebView to a pdf file?
I've tried searching for solutions in the web and I've only seen tutorials that would load a pdf file to a UIWebView. If loading the contents of a pdf file to a UIWebView could be done, then I believe that there is also a way to save the contents of a UIWebView to a pdf file.

Do anyone here have a solution?

Thanks.
Belkin_MAC is offline   Reply With Quote
Old 06-24-2009, 05:18 AM   #2 (permalink)
Apple Evangelist
 
sukumar_77's Avatar
 
Join Date: Aug 2008
Location: Mumbai
Posts: 196
Default

Quote:
Originally Posted by Belkin_MAC View Post
Hello,

Is there a way to save the contents of UIWebView to a pdf file?
I've tried searching for solutions in the web and I've only seen tutorials that would load a pdf file to a UIWebView. If loading the contents of a pdf file to a UIWebView could be done, then I believe that there is also a way to save the contents of a UIWebView to a pdf file.

Do anyone here have a solution?

Thanks.

If the content of UIWebView can be saved as image file, then we can create a pdf with the help of image. But do not know how to save the content of webview as image file as the content size would be dynamic in nature?
__________________
- Sushil
sukumar_77 is offline   Reply With Quote
Old 06-24-2009, 05:42 AM   #3 (permalink)
Registered Member
 
Join Date: Jun 2009
Posts: 18
Default

Quote:
Originally Posted by sukumar_77 View Post
If the content of UIWebView can be saved as image file, then we can create a pdf with the help of image. But do not know how to save the content of webview as image file as the content size would be dynamic in nature?
Yes. I'm also looking at that option but I also don't know how to do that.
Belkin_MAC is offline   Reply With Quote
Old 06-24-2009, 07:57 AM   #4 (permalink)
Registered Member
 
Join Date: Jun 2009
Posts: 18
Default

bump! Just bringing this thread up.
Belkin_MAC is offline   Reply With Quote
Old 06-24-2009, 08:03 AM   #5 (permalink)
Registered Member
 
Join Date: Feb 2009
Posts: 60
Default

Not sure if this is any help: JC Developer World: [iPhone] Saving an Image to the Library from UIImageView

Its about getting a UIImage out of a UIImageView and saving it in the library of the iPhone.
__________________
JeromeC is offline   Reply With Quote
Old 06-24-2009, 08:47 AM   #6 (permalink)
Registered Member
 
Join Date: Jun 2009
Posts: 18
Default

Thanks JC. This can help if there is a way that we can save the contents of UIWebview to a UIImage variable.


Quote:
Originally Posted by JeromeC View Post
Not sure if this is any help: JC Developer World: [iPhone] Saving an Image to the Library from UIImageView

Its about getting a UIImage out of a UIImageView and saving it in the library of the iPhone.
Belkin_MAC is offline   Reply With Quote
Old 06-24-2009, 07:23 PM   #7 (permalink)
Registered Member
 
Join Date: Jun 2009
Posts: 18
Default

Up! Up! Up!
Belkin_MAC is offline   Reply With Quote
Old 01-31-2011, 12:15 AM   #8 (permalink)
Registered Member
 
Join Date: Aug 2010
Posts: 14
Default

Quote:
Originally Posted by Belkin_MAC View Post
Up! Up! Up!
Hi Belkin,

Do you got any option to save Webview contents as PDF?
If yes,Kindly help Me
RUser is offline   Reply With Quote
Old 01-31-2011, 02:46 AM   #9 (permalink)
iphone developer
 
sivaram's Avatar
 
Join Date: Jun 2010
Location: Chennai
Age: 24
Posts: 32
Send a message via Skype™ to sivaram
Thumbs up

Quote:
Originally Posted by RUser View Post
Hi Belkin,

Do you got any option to save Webview contents as PDF?
If yes,Kindly help Me
To save the webview contents as an image use the following code.
Code:
	CGSize sixzevid=CGSizeMake(1024,1100);
	UIGraphicsBeginImageContext(sixzevid);
	[webview.layer renderInContext:UIGraphicsGetCurrentContext()];
	UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
	UIGraphicsEndImageContext();
	
	NSData *imageData = UIImagePNGRepresentation(viewImage);
	
	NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES);
	NSString *documentsDirectory = [paths objectAtIndex:0];	
	NSString *pathFloder = [[NSString alloc] initWithString:[NSString stringWithFormat:@"%@",@"new.png"]];
	NSString *defaultDBPath = [documentsDirectory stringByAppendingPathComponent:pathFloder];

	
	[imageData writeToFile:defaultDBPath atomically:YES];
After converting it in to an image you can easily convert it as pdf.
sivaram is offline   Reply With Quote
Reply

Bookmarks

Tags
iphone, pdf, save, uiwebview

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 912
16 members and 896 guests
Abb4ertW, Brix, cacao, Desert Diva, Diegan, glennrichard113, ios dev, Krzyloren, MarkC, mizzytheboy, nguyenhieu129, Ocguy, onzevil12, pinky, qkstrk, Snail
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,300
Threads: 89,032
Posts: 379,811
Top Poster: BrianSlick (7,086)
Welcome to our newest member, Krzyloren
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 04:25 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0