I am having difficulty with a UIWebView which shows http URLs correctly, but not bundled .pdf files.
I have also read alternative solutions such as using QuartzCore framework, however this does not seem to support multiple pages in PDFs.
Here is the code that works (for google dot com)
- (void)viewDidLoad
{
[super viewDidLoad];
NSString *pdfPath = [[NSBundle mainBundle] pathForResource:@"file" ofType:@".pdf"];
NSURL *pdfURL = [NSURL URLWithString:pdfPath];
CGRect webFrame = [[UIScreen mainScreen] applicationFrame];
webFrame.origin.y += kTopMargin - 20.0; // leave from the URL input field and its label
webFrame.size.height -= 00.0;
self.webView = [[[UIWebView alloc] initWithFrame:webFrame] autorelease];
self.webView.backgroundColor = [UIColor whiteColor];
self.webView.scalesPageToFit = YES;
self.webView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
self.webView.delegate = self;
[self.view addSubview: self.webView];
[self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.google.com"]]];
}
And for the PDF, I have replaced
[self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.google.com"]]];
with
[self.webView loadRequest:[NSURLRequest requestWithURL:pdfURL]];
My immediate thought was that the iPhone SDK does not support PDF viewing in its webview, however, tutorials like this one seem to show other users having success with this. So do you think I am just missing something in my code?
Thanks.