In order to ope local PDF file in iOS u need to do the following:
Open the "ChildBrowserViewController.m" file and edit the "loadURL" method by adding the following code:
(void)loadURL:(NSString*)url
{
NSLog(@"Opening Url : %@", url);
//Start - Added by dudi
if([url hasPrefix:@"file://"]) {
NSError *error = NULL;Code: Select all
//Create the regular expression to match against NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"file://.*/Documents/" options:NSRegularExpressionCaseInsensitive error:&error]; // Create the new string by replacing the matching of the regex pattern with the template pattern(empty string) NSString *relativeUri = [regex stringByReplacingMatchesInString:url options:0 range:NSMakeRange(0, [url length]) withTemplate:@""]; NSLog(@"New string: %@", relativeUri); NSURL *documentsDirectory = [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject]; NSURL *url = [documentsDirectory URLByAppendingPathComponent:relativeUri]; NSLog(@"New string: %@", url); NSURLRequest *request = [NSURLRequest requestWithURL:url]; [webView loadRequest:request];
}
//End - Added by dudi
else if ([url hasSuffix:@".png"]
[url hasSuffix:@".jpg"]
2.invoke the childBrowse plugin as following:
window.plugins.childBrowser.showWebPage("file:///mnt/myBill.pdf");