How to open a Word doc from phonegap

2,835 views
Skip to first unread message

Kurt

unread,
Jan 22, 2013, 10:11:56 AM1/22/13
to phon...@googlegroups.com
Hello,

I'm wondering if anyone knows how to open/view a MS Word doc in phonegap?
I see posts about the ChildBrowser being used for PDF's.  Will that work for MS Office docs?

Or do I need to create my own "plugin" and just call this from Android?

Any comments would help.
Thanks!
Kurt

Fabian Boulegue

unread,
Jan 22, 2013, 8:19:23 PM1/22/13
to phon...@googlegroups.com
Yes as Long as there is no Plugin you have to create it for this

madhu latha

unread,
Jan 23, 2013, 12:11:01 AM1/23/13
to phon...@googlegroups.com
Hi,

You can open word documents also using child browser plugin.

On Wed, Jan 23, 2013 at 6:49 AM, Fabian Boulegue <fbou...@googlemail.com> wrote:
Yes as Long as there is no Plugin you have to create it for this

--
-- You received this message because you are subscribed to the Google
Groups "phonegap" group.
To post to this group, send email to phon...@googlegroups.com
To unsubscribe from this group, send email to
phonegap+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/phonegap?hl=en?hl=en

For more info on PhoneGap or to download the code go to www.phonegap.com

To compile in the cloud, check out build.phonegap.com





--
Thanks & Regards,
Madhulatha

Paul Cervenka

unread,
Jan 23, 2013, 2:32:57 PM1/23/13
to phon...@googlegroups.com
hi,

we're viewing all office documents (doc,docx,xls,xlsx,ppt,pptx) in our cordova app with the inAppBrowser.

br, paul

Kurt

unread,
Jan 23, 2013, 5:13:03 PM1/23/13
to phon...@googlegroups.com
Thanks Paul.

I'll give that a try

Kurt

unread,
Jan 30, 2013, 12:32:56 PM1/30/13
to phon...@googlegroups.com
Paul,

So I guess the process is to upgrade to PG 2.3.0 and read up on the InAppBrowser and use it to open a PDF, or doc, ppt, etc?
Guess that is the next thing I'll try.

Any comments would be appreciated.


On Wednesday, January 23, 2013 2:32:57 PM UTC-5, Paul Cervenka wrote:

Paul Cervenka

unread,
Jan 30, 2013, 2:04:25 PM1/30/13
to phon...@googlegroups.com
Hi Kurt,

yes - or you use the "ChildBrowser" Plugin.

br, Paul

Kurt

unread,
Jan 30, 2013, 3:13:15 PM1/30/13
to phon...@googlegroups.com
Paul,

I upgraded to 2.3.0 and changed my code to use the IAB.
I am able to open a site, like www.google.com, but no PDF's.

I'm doing it like this, and I just get a white screen (no pdf).

    // hard code for now till it works.
    var fileUrl = 'file:///sdcard/Download/Menu.pdf';
    alert('attempt to open: ' + encodeURI(fileUrl));
   
    // now try inAppBrowser
    var ref = window.open(encodeURI(fileUrl), '_blank', 'location=yes');

Can you post the code snippet on how you open the PDF.

Kerri Shotts

unread,
Jan 30, 2013, 9:15:57 PM1/30/13
to phon...@googlegroups.com
Just curious, but do you have any software capable of rendering a PDF on your device?

If nothing else works, you might try pdf.js (http://mozilla.github.com/pdf.js/)

Not sure how well it would work on Android...


___________________________________
Kerri Shotts
photoKandy Studios, LLC


Social Media:
          Twitter: @photokandy, http://twitter.com/photokandy
          Tumblr: http://photokandy.tumblr.com/
          Github: https://github.com/kerrishotts
                        https://github.com/organizations/photokandyStudios
          CoderWall: https://coderwall.com/kerrishotts

Apps on the Apple Store:

--
-- You received this message because you are subscribed to the Google
Groups "phonegap" group.
To post to this group, send email to phon...@googlegroups.com
To unsubscribe from this group, send email to
phonegap+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/phonegap?hl=en?hl=en
 
For more info on PhoneGap or to download the code go to www.phonegap.com
 
To compile in the cloud, check out build.phonegap.com
---
You received this message because you are subscribed to the Google Groups "phonegap" group.
To unsubscribe from this group and stop receiving emails from it, send an email to phonegap+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Paul Cervenka

unread,
Jan 31, 2013, 5:27:24 AM1/31/13
to phon...@googlegroups.com
Hi Kurt,

I'm using inAppBrowser in iOS, so I've never tested, if you can view office documents on android with it.

Sorry =/

br, Paul

Kurt

unread,
Jan 31, 2013, 9:27:40 AM1/31/13
to phon...@googlegroups.com
Yes,

If I navigate to the file in the "My Files" and select a PDF, it opens it with "Open Office" and I can see the PDF, zoom in, etc.

Francisco

unread,
Jan 31, 2013, 2:50:23 PM1/31/13
to phon...@googlegroups.com
Hi Kurt,

A workaround (on Android) could be using this: https://docs.google.com/viewer

Load that url into Childbrowser with your document path then you'll get your doc rendered nicely on your device.

NOTE: Haven't tried inAppBrowser (in 2.3.0) as Paul suggested.

Good luck!

Kurt

unread,
Jan 31, 2013, 4:21:09 PM1/31/13
to phon...@googlegroups.com
Hi Francisco.

I tried your suggestion, and I just get a 404.
I'm wondering  - have you done this using a local file from the FS on your phone?

Kurt

unread,
Jan 31, 2013, 4:38:19 PM1/31/13
to phon...@googlegroups.com
Also,

I was able to view a PDF out on the net doing the call like this:

var fileUrl = ' http://docs.google.com/viewer?url=http%3A%2F%2Fresearch.google.com%2Farchive%2Fbigtable-osdi06.pdf';
    alert('attempt to open: ' + fileUrl);
   
    // now try inAppBrowser
    var ref = window.open(fileUrl, '_blank', 'location=yes');

I "encoded" it by hand to make sure it worked... basically the copy/paste from the google website.
But it won't work for a local file.  I tried both on my phone and also my mac (firefox and chrome both give a 404 when trying to get the local file.  I guess its a permission issue.)

Kerri Shotts

unread,
Jan 31, 2013, 4:41:22 PM1/31/13
to phon...@googlegroups.com
There'd be no way for the Google viewer to get at your local file, short of you uploading to somewhere, so that's a non-starter for you, I think.

Have you tried pdf.js? It might be your best option here…


___________________________________
Kerri Shotts
photoKandy Studios, LLC


Social Media:
          Twitter: @photokandy, http://twitter.com/photokandy
          Tumblr: http://photokandy.tumblr.com/
          Github: https://github.com/kerrishotts
                        https://github.com/organizations/photokandyStudios
          CoderWall: https://coderwall.com/kerrishotts

Apps on the Apple Store:

--

Kurt

unread,
Jan 31, 2013, 4:54:03 PM1/31/13
to phon...@googlegroups.com
Thanks for the suggestions and help.

I can't use pdf.js as I need to support all doc types, PDF, word, Excel, etc.
I'm sure the InAppBrowser is the right way to go, just need some help getting it to work on Android (people here are using it on iOS).

Ami Gandhi

unread,
Dec 12, 2013, 2:44:10 PM12/12/13
to phon...@googlegroups.com, kurtl...@gmail.com
Hi everyone!

I am also trying to use in app browser, But when I try to open any local docx or pdf files, it just show me white screen only.

Does anyone has it's solution?

Reply all
Reply to author
Forward
0 new messages