Rajesh Loganathan
Rajesh Loganathan

Reputation: 11247

IOS: How to display a document page by page in UIWebview

I need to display Pdf & Doc file format page by page. I chooses UIWebview for displaying documents. But i cant able to display page by page or differentiate page from another page.

Here is my code:

//-- Getting file path from document directory
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSFileManager *fileManager = [NSFileManager defaultManager];
NSString *fileLocation = [NSString stringWithFormat:@"%@/sample.doc",documentsDirectory];

//--UIWebview initialization
UIWebView *myWebView=[[UIWebView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
myWebView.scalesPageToFit = YES;
myWebView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:fileLocation]]];
NSLog(@"%@",[NSURL fileURLWithPath:fileLocation]); // I 
[self.view addSubview:myWebView];

Can anybody help how to display page by page.

Upvotes: 0

Views: 196

Answers (1)

Related Questions