objective c - Display PDF downloaded from URL according to individual pages -
in application have requirement displaying pdf according pages.only single page @ time next & previous buttons @ bottom.on clicking "next" load next page , on...
i know working uiwebview can display pdf, whole pdf document displayed @ time.just need display single page each time
nsurl* url = [nsurl urlwithstring:@"http://exmonthly.pdf"]; nsurlrequest* request = [nsurlrequest requestwithurl:url]; wbview.scalespagetofit=yes; [wbview loadrequest:request]; [self.view addsubview:wbview];
this code displays available pages of pdf.how can individual pages
any ideas/help thankful
apple have qlpreviewcontroller, there whole pfd if i'm not mistaken. can save pdf, next split pdf single pages (for ios see answer), make custom uiviewcontroller uiwebview , 2 buttons next & prev. next reload uiwebview read each individual page.
something this:
- (void)savepdfdatalocally { nsdata *datapdf = [nsdata datawithcontentsofurl:[nsurl urlwithstring:@"http://exmonthly.pdf"]]; //get path directory nsarray *paths = nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes); nsstring *documentsdirectory = [paths objectatindex:0]; //create pdf_documents directory documentsdirectory = [documentsdirectory stringbyappendingpathcomponent:@"pdf_documents"]; [[nsfilemanager defaultmanager] documentsdirectory withintermediatedirectories:yes attributes:nil error:nil]; nsstring *filepath = [nsstring stringwithformat:@"%@/%@", documentsdirectory, @"exmonthly.pdf"]; [datapdf writetofile:filepath atomically:yes]; } - (void)loadpage:(int)page { nsurlrequest* request = [nsurlrequest requestwithurl:[nsurl fileurlwithpath:filepath_from_previous_function]]; webview.scalespagetofit=yes; [webview loadrequest:request]; } - (ibaction)nexttap:(id)sender { currentpage++; [self loadpage:currentpage]; }
Comments
Post a Comment