I have working project in which i display pdf file in UIWebView
While testing my application in iOS8beta5 with XCode5, it did not work
In log it display failed to find PDF header : '%PDF' not found
self.myWebView.delegate = self;
NSString *path = [[NSBundle mainBundle] pathForResource:@"201" ofType:@"pdf"];
NSURL *targetURL = [NSURL fileURLWithPath:path];
NSURLRequest *request = [NSURLRequest requestWithURL:targetURL];
[self.myWebView loadRequest:request];
Quicklook framework may did not display PDF file in some application
but they did not mention any thing about UIWebView
,
Reference
I found a workaround for viewing the PDF in WebView
// Create pdf path & url
NSString *path = [[NSBundle mainBundle] pathForResource:@"201" ofType:@"pdf"];
NSURL *targetURL = [NSURL fileURLWithPath:path];
// Load pdf in WebView
NSData *pdfData = [[NSData alloc] initWithContentsOfURL:targetURL];
[self.webView loadData:pdfData MIMEType:@"application/pdf" textEncodingName:@"utf-8" baseURL:nil];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With