0

As the title says, I need to display a PDF file stored in a remote server without downloading it on the device just by using an URL link. Is it possible to do it by using the Quick Look framework?

I am using this code below:

- (void)openDocument {
    QLPreviewController *docPreviewController = [[QLPreviewController alloc] init];
    [docPreviewController setDataSource:self];
    [docPreviewController setDelegate:self];
    [docPreviewController setCurrentPreviewItemIndex:sender.tag];
    [self.destinationViewController presentViewController:docPreviewController animated:true completion:nil];
}

- (NSInteger)numberOfPreviewItemsInPreviewController:(QLPreviewController *)controller {
    return 1;
}

- (id<QLPreviewItem>)previewController:(QLPreviewController *)controller previewItemAtIndex:(NSInteger)index {
    return [NSURL fileURLWithPath:@"http://www.domain.com/file.pdf"];
}

But I have this problem in the console:

UIDocumentInteractionController: invalid scheme https.  Only the file scheme is supported.
Aluminum
  • 2,932
  • 5
  • 35
  • 63
  • Try this blog. it might be helpful for you http://kratinmobile.com/blog/index.php/document-preview-in-ios-with-quick-look-framework/ – Badal Shah Jan 21 '16 at 18:04

2 Answers2

0

No it's not supported by current QLFramework. All quicklook supported items should conforms to "QLPreviewItem" protocol. According to QL's document

The methods in the QLPreviewItem protocol are also declared as a category on the NSURL class. As a result, you can use NSURL objects directly as preview items—provided that you want to use the default titles of those items.

QLPreviewItem protocol contains previewItemURL attribute, which is a URL type. But the document tells us directly:

The value of this property must be a file-type URL.

In other words, it doesn't accept other url schema.

kakaiikaka
  • 3,530
  • 13
  • 19
-1

I have resolved by using UIDocumentInteractionController

UIDocumentInteractionController *viewer = [UIDocumentInteractionController interactionControllerWithURL:[NSURL fileURLWithPath:path]];
viewer.delegate = self;
[viewer presentPreviewAnimated:YES];
Aluminum
  • 2,932
  • 5
  • 35
  • 63