DiskImageCache: Failed to resolve the absolute path of the old directory. could not find pdf header: `% pdf 'not found

In one of my views, I just want to show a pdf file in a UIWebView.

My header file code:

#import <UIKit/UIKit.h> @interface FCOMViewController : UIViewController {IBOutlet UIWebView *fcomWebView;} //flag to denote if this is first time the app is run @property (nonatomic) BOOL firstRun; @end 

And here is the method in the implementation file:

 - (void)viewDidLoad { //Show the procedures PDF NSString *path = [[NSBundle mainBundle] pathForResource:@"b777normalprocedures" ofType:@"pdf"]; NSURL *url = [NSURL fileURLWithPath:path]; NSURLRequest *request = [NSURLRequest requestWithURL:url]; [fcomWebView loadRequest:request]; [fcomWebView setScalesPageToFit:YES]; 

The application starts normally, it does not crash and nothing. Reference outputs are set, but it does not show PDF. The console says:

DiskImageCache: Failed to resolve the absolute path of the old directory. could not find pdf header: `% pdf 'not found.

The PDF is in the project directory, I double checked that it was written correctly.

What can i do here? Any help would be appreciated.

+8
xcode pdf
source share
2 answers

Try this if you configure iOS 8.0:

  NSString *path = [[NSBundle mainBundle] pathForResource:@"b777normalprocedures" ofType:@"pdf"]; NSURL *targetURL = [NSURL fileURLWithPath:path]; NSData *pdfData = [[NSData alloc] initWithContentsOfURL:targetURL]; [_webView loadData:pdfData MIMEType:@"application/pdf" textEncodingName:@"utf-8" baseURL:nil]; 
+2
source share

For me, the problem was downloading pdf files that had extensions that I believe were otherwise recognized by UIWebView (aspx, php, etc.). When I renamed the downloaded pdf files so that they had the extension ".pdf", an error did not occur.

0
source share

All Articles