Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 29    Views: 121

miche
Apple Fan
Profile
Posts: 59
Reg: Jun 07, 2011
Lancashire, UK
3,740
12/10/12 11:15 AM (13 years ago)

PDF plugin Android

I can't seem to get the PDF plugin to work on V2.0 Android. It just keeps saying 'Something's not right' , 'File not downloaded yet'. There's a PDF reader on the phone. I've tried using different plugins, HTML doc etc...but all the same. Please help!
 
GoNorthWest
buzztouch Evangelist
Profile
Posts: 8197
Reg: Jun 24, 2011
Oro Valley, AZ
1,000,000
like
12/10/12 11:32 AM (13 years ago)
Hi @miche, Are you linking to a PDF document that's been included with the app, or via a URL? If included, then it needs to be in the BT_Docs folder when you compile the app. For both linked and local, you need to make sure that there are no spaces in the filename, or special characters. That'll throw Android every time! Mark
 
miche
Apple Fan
Profile
Posts: 59
Reg: Jun 07, 2011
Lancashire, UK
3,740
like
12/10/12 11:37 AM (13 years ago)
Hi Mark It's a link via a URL, already had the problem with spaces and special characters in the past so I made sure that wasn't the problem. This is an example of one of the URL's http://www.queens.lancsngfl.ac.uk/download/183/ICTPolicy.pdf I'm puzzled!
 
GoNorthWest
buzztouch Evangelist
Profile
Posts: 8197
Reg: Jun 24, 2011
Oro Valley, AZ
1,000,000
like
12/10/12 11:42 AM (13 years ago)
Well, that's quite strange! If you are running this through Eclipse, is there any LogCat output that might show what's going on?
 
miche
Apple Fan
Profile
Posts: 59
Reg: Jun 07, 2011
Lancashire, UK
3,740
like
12/10/12 11:54 AM (13 years ago)
Yes using eclipse, does this shed any light.... 12-10 18:47:50.935: W/ZZ(308): BT_downloader:downloadAndSaveBinaryData from URL EXCEPTION: java.lang.NegativeArraySizeException URL: http://www.queens.lancsngfl.ac.uk/download/183/ICTPolicy.pdf 12-10 18:47:54.747: W/ZZ(308): BT_screen_pdfDoc:openDocInCache: E34AE6E7EE4B6D0CD9C4B3B_screenData.pdf 12-10 18:47:54.805: W/ZZ(308): BT_screen_pdfDoc:openDocInCache Cannot open document, not in cache yet: E34AE6E7EE4B6D0CD9C4B3B_screenData.pdf
 
GoNorthWest
buzztouch Evangelist
Profile
Posts: 8197
Reg: Jun 24, 2011
Oro Valley, AZ
1,000,000
like
12/10/12 12:04 PM (13 years ago)
That probably says a lot, but since I'm not skilled in the art of Java, I'll bring this thread to the attention of David @ buzztouch! He'll probably be able to diagnose it super quick! Hang tight on this...we'll get it resolved as quickly as possible! Mark
 
miche
Apple Fan
Profile
Posts: 59
Reg: Jun 07, 2011
Lancashire, UK
3,740
like
12/10/12 12:10 PM (13 years ago)
Thank you so much
 
Crown Solutions
Aspiring developer
Profile
Posts: 463
Reg: Nov 11, 2011
MN
13,480
like
12/10/12 12:29 PM (13 years ago)
Try renaming your PDF to one that does not have any caps. ex- ict_policy.pdf
 
GoNorthWest
buzztouch Evangelist
Profile
Posts: 8197
Reg: Jun 24, 2011
Oro Valley, AZ
1,000,000
like
12/10/12 12:31 PM (13 years ago)
I was thinking that as well, but I have an Android app with PDF files that have caps in them, and it works just fine. I was wondering about the length of the first part of the URL...it's longer than the standard www.something.com. Mark
 
AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
like
12/10/12 12:35 PM (13 years ago)
Does your app have permission to access the internet?
 
Crown Solutions
Aspiring developer
Profile
Posts: 463
Reg: Nov 11, 2011
MN
13,480
like
12/10/12 12:38 PM (13 years ago)
Good point Mark, I would also check the file size. If it is a rather large file, it may have an issue. Maybe try putting the file on Dropbox, or try with a smaller file to help diagnose where the issue is coming from.
 
GoNorthWest
buzztouch Evangelist
Profile
Posts: 8197
Reg: Jun 24, 2011
Oro Valley, AZ
1,000,000
like
12/10/12 12:45 PM (13 years ago)
Another test would be to put the file locally with the app, in the BT_Docs folder, and see if that changes anything.
 
ianJamesPiano
Code is Art
Profile
Posts: 2661
Reg: Feb 13, 2011
Palm Springs, C...
37,010
like
12/10/12 12:51 PM (13 years ago)
Would be worth trying something like tinyurl.com if the length of the original link is giving problems? Try this? http://tinyurl.com/cuswlv3
 
GoNorthWest
buzztouch Evangelist
Profile
Posts: 8197
Reg: Jun 24, 2011
Oro Valley, AZ
1,000,000
like
12/10/12 01:08 PM (13 years ago)
Lots of great suggestions!
 
miche
Apple Fan
Profile
Posts: 59
Reg: Jun 07, 2011
Lancashire, UK
3,740
like
12/10/12 01:10 PM (13 years ago)
I've had to scrap using the PDF plugin, tried all suggestions no joy :-( So I've chosen to use 'Launch Native App' the set it to launch 'Browser - enter URL' i've then put the URL for the PDF. This has solved it, it comes up with the option to choose a Browser to launch it, then hey presto the PDF shows no problem. Thanks all! Miche :-)
 
GoNorthWest
buzztouch Evangelist
Profile
Posts: 8197
Reg: Jun 24, 2011
Oro Valley, AZ
1,000,000
like
12/10/12 01:20 PM (13 years ago)
Glad it worked out, but I'm not liking that you had to do it that way! We'll continue to investigate, and perhaps you can go back to the correct screen soon! Mark
 
LA
Aspiring developer
Profile
Posts: 3280
Reg: Aug 16, 2012
Jerseyville, IL
42,900
like
12/10/12 01:30 PM (13 years ago)
Hey @GoNorthWest, Maybe the pdf reader is not installed? LA
 
GoNorthWest
buzztouch Evangelist
Profile
Posts: 8197
Reg: Jun 24, 2011
Oro Valley, AZ
1,000,000
like
12/10/12 01:41 PM (13 years ago)
"There's a PDF reader on the phone." - first thing she said!
 
LA
Aspiring developer
Profile
Posts: 3280
Reg: Aug 16, 2012
Jerseyville, IL
42,900
like
12/10/12 01:43 PM (13 years ago)
Yes sorry! LA
 
miche
Apple Fan
Profile
Posts: 59
Reg: Jun 07, 2011
Lancashire, UK
3,740
like
12/10/12 02:07 PM (13 years ago)
Hope there is a solution for the PDF plugin for future use. I look forward to finding out. Many thanks all again Miche
 
ianJamesPiano
Code is Art
Profile
Posts: 2661
Reg: Feb 13, 2011
Palm Springs, C...
37,010
like
12/10/12 02:56 PM (13 years ago)
Hi miche, I haven't done this with a v2.0 app yet but will check later on my computer. I am sure they will have the plugin updated quickly though:) This is what I did in an older v1.5 Android app so the PDF opened in the devices PDF reader instead of asking for browser or program which saves a step and feels more pro. http://www.buzztouch.com/files/howtos/intercepting-menu-taps.pdf Again, I am sure the plugin will be updated but it is neat stuff in this How To. Let me know if u need help:)
 
miche
Apple Fan
Profile
Posts: 59
Reg: Jun 07, 2011
Lancashire, UK
3,740
like
12/10/12 03:08 PM (13 years ago)
@ianjamespiano Thanks for the link. I will explore it in more detail. I miss some of the v1.5 feature :-( but hopefully v2.0 will be updated soon. Miche
 
David @ buzztouch
buzztouch Evangelist
Profile
Posts: 6866
Reg: Jan 01, 2010
Monterey, CA
78,840
like
12/10/12 03:24 PM (13 years ago)
Fixed. Fun to sleuth out. The details.....NERDS ONLY. --This issue was NOT being caused by the PDF Plugin. I've been testing since this thread began and was able to duplicate this problem with the same URL @Miche is using. Testing on several devices, NONE of them would show this PDF. A regular browser on a regular computer, or on a mobile device had no problem whatsoever. There isn't anything wrong with the PDF or it's file name. In this case the File Name (at the end of the URL) doesn't even matter, it's not used in this case. --This plugin, and a few others, rely on the BT_downloader.java file in the BT Core Code to fetch files from URL's. In this case, a Binary File. This is different than textual type data like HTML, JSON, XML, etc. Binary files are things like images, PDF, Excel, Word, etc. --The BT_downloader.java file has a method called downloadAndSaveBinaryData() that begins on line 201. This is the method that was NOT working. It is now. The BT_downloader.java file in your Android projects has been updated. The previous implementation worked on lots and lots of PDF's but not this one. Strange. As it turns out, the Server (that hosts this PDF) was not returning the Content Length property of the PDF in the HTTP Response Headers. The idea is that when you download something from a URL the server hosting the file returns the length (size) of the document along with the content so the browser, phone, whatever client is downloading it knows how large it is and what to expect. This was not happening. The host was returning the proper content type and other details but -1 as the length. Because the BT_downloader.java class relies on the length of something being downloaded, it simply didn't do anything. It figured there was nothing to download because -1 was the length. Crazy. My suspicion is that the server administrator that controls all sorts of things on this server COULD make some adjustments to ensure that the Content Length is returned with PDF type documents (when requested). But, there isn't any sense in going that route, it's very a complicated concept, we have no idea who this administrator is, and it's not possible. It would have fixed this but it's not a good solution. I'll bet there are gazillions of HTTP Responses with PDF data that also don't return a length! I suppose I could email every web-host administrator on earth and kindly ask them to make sure their backends are returning Content Length values for every document they host. Ha! Funny. I re-worked the methodology in the downloadAndSaveBinaryData() so it doesn't rely on the Content Length value being more than zero. I did this because I'll bet this isn't the only time this has happened and figured this would solve future problems as well? Dunno, just a hunch. Tested on several devices after the code improvement / change. All is well. Heck, it may even be faster now? LOL. Re-fetch your project so it has the newly updated BT_downloader.java file and it will work on this URL and others. d.
 
ianJamesPiano
Code is Art
Profile
Posts: 2661
Reg: Feb 13, 2011
Palm Springs, C...
37,010
like
12/10/12 03:31 PM (13 years ago)
Sweetness!
 
GoNorthWest
buzztouch Evangelist
Profile
Posts: 8197
Reg: Jun 24, 2011
Oro Valley, AZ
1,000,000
like
12/10/12 03:35 PM (13 years ago)
Awesome! Great fix, David! Great bug find, @miche! As David said, you'll need to download your source code again to pick up the fix, but you should be able to go back to using the PDF Screen now. Let us know how it goes! Mark
 
miche
Apple Fan
Profile
Posts: 59
Reg: Jun 07, 2011
Lancashire, UK
3,740
like
12/10/12 03:35 PM (13 years ago)
I love Buzztouch!! Thanks once again David :-) Miche = one happy bunny
 
miche
Apple Fan
Profile
Posts: 59
Reg: Jun 07, 2011
Lancashire, UK
3,740
like
12/10/12 03:39 PM (13 years ago)
@gonorthwest will do!
 
ATRAIN53
Code is Art
Profile
Posts: 1755
Reg: Nov 17, 2011
Chicago
26,450
like
12/11/12 07:49 AM (13 years ago)
awesome. I gave up on the Android PDF via URL's long ago due to similar issues. just unpredectable. The 2nd step of having to have a PDF app on the phone and the user to select it before it launches was also causing me headaches. I converted them into images and was looking at some other options. We can just replace that single BT_downloader.java file in existing Self Hosted projects too? (and thanks for spending the day addressing the issue)
 
David @ buzztouch
buzztouch Evangelist
Profile
Posts: 6866
Reg: Jan 01, 2010
Monterey, CA
78,840
like
12/11/12 12:36 PM (13 years ago)
BT_downloader.java comes from our end on self hosted - you dont' have it so it will be good when you download the next project from your self hosted panel.
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
12/11/12 08:30 PM (13 years ago)
Thanks David for the excellent explanation! I recently added support in my app for pdf documents, but haven't done extensive testing on the Android side. When I first started reading this thread I got nervous, but your explanation helped me understand exactly why miche was having a problem and whether I need to issue an update to the app store right away or not. One more reason why I love Buzztouch!
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.