0

I am trying to display a PDF from a server in my app.

I tried going the route of Document Interaction Controller, but that only display files within a app, not off the web :(

if (URL) {
    // Initialize Document Interaction Controller
    self.documentInteractionController = [UIDocumentInteractionController interactionControllerWithURL:URL];

    // Configure Document Interaction Controller
    [self.documentInteractionController setDelegate:self];

    // Preview PDF
    [self.documentInteractionController presentPreviewAnimated:YES];
}

Would UIWebView be my best solution to display PDF from server? Not a PDF on a website, but on a server \SEVERNAME\LHSD\PDFs\example.pdf

user979331
  • 11,039
  • 73
  • 223
  • 418

1 Answers1

1

The best way to display pdf file in objective-c is load pdf file in UIWebView.

Try this :

NSString *stringUrl = @"YOUR-SERVER'S-PDF-FILE-URL";
    NSURL *url = [NSURL URLWithString:stringUrl];
    NSURLRequest *request = [NSURLRequest requestWithURL:url];

UIWebView *webViewObj = [[UIWebView alloc] initWithFrame:CGRectMake(10, 10, 300, 450)];
    [webViewObj loadRequest:request];
    [self.view addSubview:webViewObj];
Mehul Sojitra
  • 1,181
  • 9
  • 15