USER
USER

Reputation: 21

How to zoom webView with pdf file

How to get zoom in UIWebView.

I loaded pdf file from resource bundle in a UIWebView.

Now trying to zoom the webview. so its will get zooming effect to the pdf file.

So.

How can i zoom the UIWebView.

Any sample example. Please help me out.

Upvotes: 2

Views: 4038

Answers (3)

Shantanu
Shantanu

Reputation: 3136

Just use the following code:

self.pdfviewwebview.scalesPageToFit = YES;
self.pdfviewwebview.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
self.pdfviewwebview.delegate = self;

The most tricky thing here which most people forget is to set the webview's delegate,so take care about that.

Upvotes: 5

sheisd
sheisd

Reputation: 179

UIWebView *tempWebView = [[UIWebView alloc] initWithFrame:CGRectMake(0.0, 0.0, self.view.bounds.size.width, self.view.bounds.size.height)];  
tempWebView.backgroundColor = [UIColor whiteColor];  
**tempWebView.scalesPageToFit = YES; //this enables the zooming**
tempWebView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
tempWebView.delegate = self;
[self.view addSubview:tempWebView]; 
[self setWebView:tempWebView];


NSString *path = [[NSBundle mainBundle] pathForResource:@"your_file" ofType:@"pdf"];
NSURL *targetURL = [NSURL fileURLWithPath:path];
NSURLRequest *request = [NSURLRequest requestWithURL:targetURL];
[self.webView loadRequest:request];

Upvotes: 2

BearDroid
BearDroid

Reputation: 583

A pinch-to-zoom gesture can be simulated by holding down the Option key. On your simulator, two grey circles will appear indicating that its simulating a multi-touch, pinch-to-zoom gesture.

Upvotes: -1

Related Questions