Embed PDF Viewer for PhoneGap application

3 Solutions Collect From Internet About “Embed PDF Viewer for PhoneGap application”

There’s not much documentation for mixing PhoneGap and ObjC, but here is some example code that lets you embed PhoneGap with an ObjectiveC-Application. For the PDF viewer, you can either use basic ones like Apple’s QuickLook or UIWebView, or more advanced ones like PSPDFKit.

For Android, you could simply search for an Intent that is capable of displaying pdf (like Adobe’s official Reader for Android) or integrate a full PDF viewer yourself. There’s an open source project for that, but it looks not quite complete. Or check out apv, or droidreader, which is GPLv3.

I only have iOS phonegap experience. The solution that has worked for me is to make a plugin that pops up a native webview that uses iOS native pdf viewer. The way to get this to work is to follow the instructions on this website.

http://spin.atomicobject.com/2010/12/07/updating-phonegap-s-childbrowser-plugin-to-handle-local-files/

This link modifies an existing plugin, “Child browser” to use the native webview display pdf’s. The original chilbrowser plugin can be found here.

To give you more of an idea of what it will be like, here is my particular javascript call that I put into my sencha application.

 PhoneGap.exec("ChildBrowserCommand.showFilePage", GlobalVar.localRoot + "/" + record.get("FilePath"));

This is inside the handler for the buttonTap inside the sencha, pressing the button will then call the objective C method “showFilePage”. The parameter is the filepath that the plugin will use.

Here is the Objective C part (again, you should follow the links for full instructions)

    - (void) showFilePage:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options // args: url
{   
    NSLog(@"showFilePage entered: ");
    if(childBrowser == NULL)
    {
        childBrowser = [[ ChildBrowserViewController alloc ] initWithScale:FALSE ];
        childBrowser.delegate = self;
    }




    PhoneGapViewController* cont = (PhoneGapViewController*)[ super appViewController ];
    childBrowser.supportedOrientations = cont.supportedOrientations;
    [ cont presentModalViewController:childBrowser animated:YES ];

    NSString *path = (NSString*) [arguments objectAtIndex:0];
    NSLog(@"Our argument 0 is: %@",[arguments objectAtIndex:0]);

    NSLog(@"The url is: %@",path);
    [childBrowser loadFileURL:path];

}

Hi just use HTML5 object tag, you can add,swf, pdf etc..