Skip to first unread message

Mattt586

unread,
Jan 21, 2015, 5:24:09 AM1/21/15
to mitappinv...@googlegroups.com
Hi I want to open a odd from a website in my app. I have done this but the google doc viewer is rubbish when trying to zoom it goes all over the place.

I've decided I want the app to download the pdf first then open in a better external pdf viewing app like adobe.

Can anyone help?
Cheers
Matt

SteveJG

unread,
Jan 21, 2015, 8:02:29 AM1/21/15
to mitappinv...@googlegroups.com
Taifun's tutorial here may give you some ideas:   http://puravidaapps.com/snippets.php#2pdf  

Regards,
Steve

Mattt586

unread,
Jan 21, 2015, 9:45:31 AM1/21/15
to mitappinv...@googlegroups.com
Thanks for the reply.I've been using this but it does not explain how to do what I'm asking.

Taifun

unread,
Jan 21, 2015, 10:09:44 AM1/21/15
to mitappinv...@googlegroups.com
I've been using this but it does not explain how to do what I'm asking. 
because it's self explaining, isn't it?
the first example reads a pdf stored on your device using the activity starter
the second example reads a pdf stored online using the webviewer 
try the first example...

and in case your question is, how to download a file, see here
Taifun

Mattt586

unread,
Jan 21, 2015, 11:11:35 AM1/21/15
to mitappinv...@googlegroups.com
I have tried using both of them already and it didn't work.

I did the download one when button clicked and then the view pdf from the get file and nothing happened.

I will post a screenshot later when I'm home.

Thanks

Mattt586

unread,
Jan 21, 2015, 2:31:47 PM1/21/15
to mitappinv...@googlegroups.com
appinventor.jpg

Mattt586

unread,
Jan 21, 2015, 3:31:47 PM1/21/15
to mitappinv...@googlegroups.com
just noticed it says pdf and not application/pdf still makes no difference.

I get error601: no corresponding activity was found

Taifun

unread,
Jan 21, 2015, 3:46:20 PM1/21/15
to mitappinv...@googlegroups.com
remove the activity class and use DataType = application/pdf instead
see again here How to view a pdf document 
Taifun

Mattt586

unread,
Jan 21, 2015, 4:00:49 PM1/21/15
to mitappinv...@googlegroups.com
sorry i must of clicked that and changed it by mistake. 

I have put it right and it open adobe but then said "the document can not be opened"

???

Taifun

unread,
Jan 21, 2015, 4:16:25 PM1/21/15
to mitappinv...@googlegroups.com
well, your download link somehow does not look correct...
Taifun

Mattt586

unread,
Jan 21, 2015, 4:21:47 PM1/21/15
to mitappinv...@googlegroups.com
can you explain? ive tried another also

Mattt586

unread,
Jan 21, 2015, 4:23:33 PM1/21/15
to mitappinv...@googlegroups.com

Taifun

unread,
Jan 21, 2015, 4:40:48 PM1/21/15
to mitappinv...@googlegroups.com
OK, the link works
How does the complete path of the downloaded file in your device look like ? Make sure, it starts with file:///mnt/sdcard/...
Taifun

Mattt586

unread,
Jan 21, 2015, 4:45:31 PM1/21/15
to mitappinv...@googlegroups.com
the path is /storage/emulated/o/AppInventor/assets

Taifun

unread,
Jan 21, 2015, 4:55:47 PM1/21/15
to mitappinv...@googlegroups.com
try to use the join block and add file:// 
what is the filename currently?
you also might want to define the filename using the Web.ResponseFileName block, see also https://puravidaapps.com/filebyfile.php
Taifun

Mattt586

unread,
Jan 21, 2015, 4:58:11 PM1/21/15
to mitappinv...@googlegroups.com
Actually cancel that i think thats when i added the file to media thinking it could be stored in the app that way.

Will look for the file now

Mattt586

unread,
Jan 21, 2015, 5:00:32 PM1/21/15
to mitappinv...@googlegroups.com
its in /storage/sdcard0/My Documents/Downloads

It opens with adobe from there??

Mattt586

unread,
Jan 21, 2015, 5:10:19 PM1/21/15
to mitappinv...@googlegroups.com
Thanks that has sorted it!
Now i can actually view pdf properly! Now to build the app.

One more thing. 
Will it download and open the file every time its pressed or will it know its already there the second time and just open it? 

appinventor.jpg

Mattt586

unread,
Jan 21, 2015, 5:13:37 PM1/21/15
to mitappinv...@googlegroups.com
Another problem. When I swapped it back to the actually file i want it to work with not the one i was testing it with. It says in adobe. This document cannot be opened because its not a valid PDF document.???

Mattt586

unread,
Jan 21, 2015, 5:15:24 PM1/21/15
to mitappinv...@googlegroups.com
Sorry fo all the separate messages.

It saves the file as HTML?

Using this one again

Taifun

unread,
Jan 22, 2015, 8:36:47 AM1/22/15
to mitappinv...@googlegroups.com
instead of guessing: to find out the filename and path of the downloaded file, use a label component in the Web1.GotFile event like this
set Label1.Text to get filename

then read this again:

Mattt586

unread,
Jan 22, 2015, 10:55:48 AM1/22/15
to mitappinv...@googlegroups.com
I know the location it downloads to as said above.

It downloads the one from a website as a odd but it downloads the file from google drive as html?? Its defiantly a pdf file and downloads on pc and my phone from browser as a pdf??

Mattt586

unread,
Jan 22, 2015, 11:00:13 AM1/22/15
to mitappinv...@googlegroups.com
Sorry phone guesses words. It's said odd instead of PDF!!

Taifun

unread,
Jan 22, 2015, 11:39:36 AM1/22/15
to
please provide a screenshot of your label1.text result...

Mattt586

unread,
Jan 22, 2015, 12:49:16 PM1/22/15
to mitappinv...@googlegroups.com
I will do later as I'm not on it at the moment.Thanks again for your help.

Mattt586

unread,
Jan 22, 2015, 2:21:22 PM1/22/15
to mitappinv...@googlegroups.com
Screenshot_2015-01-22-19-13-04.png
Screenshot_2015-01-22-19-13-00.png

Taifun

unread,
Jan 22, 2015, 2:46:49 PM1/22/15
to mitappinv...@googlegroups.com
what about following this advice?

Mattt586

unread,
Jan 22, 2015, 3:21:50 PM1/22/15
to mitappinv...@googlegroups.com
Doesn't that just instruct where to save the file? Its still going to save it as a html in whatever folder i tell it to save it to. Or am i wrong?

Taifun

unread,
Jan 22, 2015, 3:32:19 PM1/22/15
to mitappinv...@googlegroups.com
let's take a look, what the documentation is saying http://ai2.appinventor.mit.edu/reference/components/connectivity.html#Web

ResponseFileName
The name of the file where the response should be saved.

so if you expect a pdf file, why not just assigning a filename?
for example
set Web.ResponseFileName to "MattWhyDontYouJustTryIt.pdf"
or
set Web.ResponseFileName to "/MattsFolder/MattWhyDontYouJustTryIt.pdf"
 
Taifun

Mattt586

unread,
Jan 22, 2015, 3:44:31 PM1/22/15
to mitappinv...@googlegroups.com
i tried that ages ago and it does not work!




Screenshot_2015-01-22-20-41-23.png
Screenshot_2015-01-22-20-41-23.png

Mattt586

unread,
Jan 22, 2015, 3:47:08 PM1/22/15
to mitappinv...@googlegroups.com
screen of the code
bm.jpg

Taifun

unread,
Jan 22, 2015, 4:07:23 PM1/22/15
to mitappinv...@googlegroups.com
your link was not correct, see also here http://techathlon.com/download-shared-files-google-drive/
like this it works...

example project attached
Taifun
mattt.aia
Message has been deleted

Mattt586

unread,
Jan 22, 2015, 4:35:17 PM1/22/15
to mitappinv...@googlegroups.com
Thanks alot your example does exactly what was required. Thanks again for working this out for me!

I would never of got to that.
Reply all
Reply to author
Forward
0 new messages