Breaking News
Home / iOS / iOS Snippets / How to display a local PDF file in iOS UIWebView?

How to display a local PDF file in iOS UIWebView?

Snippet

  1. (void) displayLocalPdfInWebView
  2. {
  3.         CGRect rect = [[UIScreen mainScreen] bounds];
  4.         CGSize screenSize = rect.size;
  5.        
  6.         UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(0,0,screenSize.width,screenSize.height)];
  7.         webView.autoresizesSubviews = YES;
  8.         webView.autoresizingMask=(UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth);
  9.        
  10.         NSString *urlAddress = [[NSBundle mainBundle] pathForResource:@"JaapSahib-Gurmukhi" ofType:@"pdf"];
  11.        
  12.         NSURL *url = [NSURL fileURLWithPath:urlAddress];
  13.         NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url];
  14.        
  15.         [webView loadRequest:urlRequest];
  16.        
  17.         [window addSubview:webView];
  18.         [webView release];
  19.        
  20. }
[pb_builder]

Check Also

EKCalendar – That account does not allow calendars to be added or removed

Usecase When I am trying to create a new Calendar programmatically using the EventKit API …

Advertisment ad adsense adlogger