views:

252

answers:

1

In my app i have shown pdf from the remote server using webview and i have to add a action to download the pdf and save it into iPhone how to do...Using Php i tried to force download pdf,which works in browser(desktop) not in device

Can any one help me...

+1  A: 

The (unjailbroken) iPhone's Safari cannot access the local file system, so it's impossible to download anything.

(The iPad, OTOH, may support it.)

KennyTM
url= @"http://localhost/abc.pdf"theRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:url] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:kTimeoutLongInterval];NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self]; if (theConnection) { receivedData=[[NSMutableData data] retain];Can i save the 'receivedData' has a pdf is it possible?I found a example of getting image in received data and which is saved in device imgDownload.image = [UIImage imageWithData:receivedData];Is that possible in PDF?
Dinesh Kumar
Yes you can save the PDF, but only your app can read it. Saving as image requires the file to be an image first.
KennyTM
Hi kennyTM,Thanks for the reply,Can u say me how can i save the received data as a pdf?
Dinesh Kumar
@user: `[data writeToFile:@"somefile.pdf" atomically:YES];`
KennyTM
Kenny can u post me a brief code...I tried but i could nt recognize that whether file was writed or not especially in simulator...how can i view the file?
Dinesh Kumar
@user: http://developer.apple.com/iphone/library/documentation/Cocoa/Conceptual/BinaryData/BinaryData.html
KennyTM