ios - When we open pdf in iPhone then how to save this pdf in iphone -
i new ios. create pdf , load pdf on uiwebview
time want save or download pdf in iphone when tapped download button exits pdf supporter show open ibook ,open in chrome. type of option show when tap 1 application closed.

-(void)show_button { nsarray *docdirectories = nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes); nsstring *docdirectory = [docdirectories objectatindex:0]; nsstring *filepath = [docdirectory stringbyappendingpathcomponent:@"mypdf.pdf"]; nslog(@"filepath = %@", filepath); nsurl *url2 = [nsurl fileurlwithpath:filepath]; nslog(@"url2 = %@", url2); uidocumentinteractioncontroller *doccontr = [uidocumentinteractioncontroller interactioncontrollerwithurl:url2]; doccontr.delegate=self; [doccontr presentopeninmenufromrect:cgrectzero inview:self.view animated:yes]; } so how save or download pdf in iphone please solve problem....
i believe can simple use belo 2 line:
nsdata *myfile = [nsdata datawithcontentsofurl:[nsurl urlwithstring:@"your_url"]]; [myfile writetofile:[nsstring stringwithformat:@"%@/%@", [[nsbundle mainbundle] resourcepath], @"yourfilename.pdf"] atomically:yes];
Comments
Post a Comment