Discussion Forums  >  Images, Documents, File Locations

Replies: 11    Views: 321

puddrix
Apple Fan
Profile
Posts: 16
Reg: Jan 11, 2012
Australia
3,060
02/23/15 03:21 AM (9 years ago)

Best method to be able to update/save .pdf via Html Doc plugin?

Hi guys, probably a rookie question but i've been trying a few things to work out what the best method would be for me to essentially modify a blank page template (that i've designed to re-use, modifying text and such) to be something new every few days then export as pdf. I thought i could just name it the same thing and it would update itself like that but there seems to be issues taking that road. Anyone done anything similar or can suggest what i'm best doing? Original plan was to update via dropbox in some way but i've found that's not as simple as first thought. Forgive my ignorance this is my first app i've just finished (probably shine up the edges a little next update) and i'm pretty excited and would like to get everything all up and running the best way possible. I should add I have uploaded to iTunes connect and currently running via test flight on my phone. That is how I have observed it doesn't update like i was hoping.. Please let me know if any of that doesn't make sense and i appreciate any input that can be offered :) thanks
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
02/23/15 08:37 PM (9 years ago)
Similar to answering a different kind of question, the rules are still the same. If you 'include' the file in the app bundle, then it will read and display the file, but you can't make changes. If you provide the file via dataURL, the user will need to 'select' that screen for the app to download the file and display it. It will also 'cache' the file for later use. Unless the user emptys the cache (not normal) it may never know you've updated the dataURL with a new version of the same filename. So what you'll want to end up doing is releasing a bundled file with the name 'myFile.pdf', and later on updates, change it (in your app/screen control panel page) to a dataURL with 'http://myserver.com/myFile1.pdf', and later 'http://myserver.com/myFile2.pdf' etcetera. A bit cumbersome, but a surefire way to keep things moving the way you want them to, transparent to the user. Just my 2¢ Cheers! -- Smug
 
puddrix
Apple Fan
Profile
Posts: 16
Reg: Jan 11, 2012
Australia
3,060
like
02/24/15 03:09 AM (9 years ago)
I see what you're saying. I did try to do this somewhat but obviously due to the fact I included the file in the bundle rather than use the dataURL it wouldn't work. Thanks mate, i'll give it a try and no doubt be back on here if no success!
 
puddrix
Apple Fan
Profile
Posts: 16
Reg: Jan 11, 2012
Australia
3,060
like
02/26/15 02:58 AM (9 years ago)
Ok seems I did misunderstand as I haven't yet attempted to utilise dataURL. I have taken a look and completely understand what you mean now but would love some assistance as to how I can correctly set this up to several of my pages can be updated as per your idea above. I'm a little overwhelmed by certain aspects of setting up dataURL.. Just to clarify, and just to emphasise my central priority in refreshing the documentation, i'd even be happy to use dropbox links as per my document updates if it wasn't for the site coming up and the user having to select "Download" every time. So obviously the dataURL method would be ideal unless there's any other simpler ideas out there? Again, bit of a noob so forgive my ignorance. Any help appreciated :) Also I should add i tried the old dropbox '?d=1' trick to try and force the download automatically as a temporary solution at least but I just get pages of assorted text and/or code..
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
02/26/15 03:48 AM (9 years ago)
Well, here's something you need to be aware of... although 'you can' use dropbox as a location for dataURL, there have been issues when the app became popular, and dropbox 'killed' the link due to traffic. Bad juju, and you don't want that to happen. Best case is to have your own web space, which is usually not a problem if you host your own websites or BT self hosted server. Otherwise you might want to take a look at other providers beside dropbox. Depending on the type of document and/or plugin, a few have a 'no-cache' setting (CustomURL, HTMLDoc) that will force a refresh each and every time. With those, you don't need to worry about name changing. But for others that 'do not' have a no-cache setting, changing the filename is about the only way to ensure a clean refresh. The way it is 'supposed' to work is, you build your app. It has a certain configuration that is provided to the app (BT_config.txt). Each and every time the app starts up, the config is loaded, and the first thing it does is go online and see if the configuation has changed, and if a new configuration is available. If so, it downloads the new config, and saves it to the app cache. If not, it keeps the 'most recent' configuration that it already has. That's one part. With respect to 'screens' (or plugins, same thing, mostly) when the user taps on a menu or whatever and a screen loads, the screen configuration is pulled from 'the most current configuration available'. It looks to see if the file is local or a dataURL. Then, it checks to see if a copy of the file (regardless of local/dataURL) is available in the cache. If so, it loads from cache. If not, it refreshes from the source (whether that source is local or dataURL). So, a 'real world' scenario would be, the user taps on the menu, the screen loads. The configuration for that screen says that the dataURL wants a file called 'mycoolfile.pdf'. It looks in the cache for a file called mycoolfile.pdf, and if it does not find one, it will download a copy to the cache. 'from that point on', when the screen is loaded and the config says 'mycoolfile.pdf', it looks in the cache, finds it in the cache, and loads it. Now, if you 'update' mycoolfile.pdf but do not change the filename or dataURL to a different name, it will load the config, see that it needs 'mycoolfile.pdf', and it will 'find' that file in the cache, and load the 'old' config, because it has no way of realizing that you've updated it (unless this is a plugin that has a no-cache setting). So, in order to 'guarantee' a refresh when you update the file, is to save the filename as a slightly different filename, and reflect the dataURL appropriately. so, if you want the user to get your update, save the file and change the dataURL to point to "mycoolfile_1.pdf" and it will look in the cache, not find it, and download a copy for the user. You 'can' bounce between old and new filenames, as long as the configuration is different... but it's just as easy, and probably better in the long run, to 'increment' your filenames so that you can keep somewhat of a 'version' record of where your file is, update wise... Does that make sense? A bit long winded, but perhaps necessary. Of course, if you have other questions, bring'em on. Cheers! -- Smug So, I realize I say 'so' a lot, lol! Mea Culpa.
 
puddrix
Apple Fan
Profile
Posts: 16
Reg: Jan 11, 2012
Australia
3,060
like
02/26/15 05:22 AM (9 years ago)
Wow thanks Smug, all totally makes sense and yeah i'd say at it had to be long enough to cover it properly! Your explanation is very much appreciated. Haha keep the 'so's' coming! hmm so I am using HTML Docs and I have about 3 pages i'd like to update/refresh probably once to twice a week each if possible, most of the time once a week. So i guess the question is how do I go about implementing either solution? I don't have my own webspace but I did a bit of digging to see what was a quick/easy solution for the time being without a great deal of luck. A majority appear to be dropbox clones and the couple I tried anyway I'd get the pages of erratic text each time I attempted. So i'm guessing i have to modify the dataURL on the main page to check the config for these updated changes? That is the part i'm a little unsure of actually, well, implementing? I'm sure it's moderately simple but I guess i'm asking what exactly do I modify/implement in the dataURL (assuming it's only the one on the main page of my control panel)? I do understand your explanation but I guess i'm missing the 'starting point'? Thanks ALOT, Dave
 
puddrix
Apple Fan
Profile
Posts: 16
Reg: Jan 11, 2012
Australia
3,060
like
02/26/15 05:27 AM (9 years ago)
Wow thanks Smug, all totally makes sense and yeah i'd say at it had to be long enough to cover it properly! Your explanation is very much appreciated. Haha keep the 'so's' coming! hmm so I am using HTML Docs and I have about 3 pages i'd like to update/refresh probably once to twice a week each if possible, most of the time once a week. So i guess the question is how do I go about implementing either solution? I don't have my own webspace but I did a bit of digging to see what was a quick/easy solution for the time being without a great deal of luck. A majority appear to be dropbox clones and the couple I tried anyway I'd get the pages of erratic text each time I attempted. So i'm guessing i have to modify the dataURL on the main page to check the config for these updated changes? That is the part i'm a little unsure of actually, well, implementing? I'm sure it's moderately simple but I guess i'm asking what exactly do I modify/implement in the dataURL (assuming it's only the one on the main page of my control panel)? I do understand your explanation but I guess i'm missing the 'starting point'? Thanks ALOT, Dave
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
02/26/15 07:54 AM (9 years ago)
Well, make sure that you have a 'public' directory for dropbox. They don't do that 'by default' anymore, so you'll have to do that yourself. There are instructions in the dropbox faq, if I'm not mistaken. If not, google it; there's a million explanations on how to do that. Once you have a 'public' directory, copy your desired html files to that location, noting the 'public' address for those pages. On mine, it looks sort of like this: https://dl.dropboxusercontent.com/u/000000000/leaves/javaleaves.html ( the 000000000 is your personal 'ID' number.) That would be the address you would use as your dataURL URL (using your own path and filename). Anytime you make an update, you would 1) Create or alter the file, and save it as a new filename in your 'host'. 2) Go to your app control panel, to the correct screen configuration page, and change the dataURL to reflect the 'correct' page. 3) 'Publish' the changes in your app control panel (there's more to this, but for the moment, just go through the motions and do it) And that 'should' be all there is to it. If it doesn't look right in dropbox, then I'd check things like 'dependancy' paths for Java, CSS or something like that... it also needs to match the 'full internet path' as well. even if all documents reside in the same directory, the html page will load 'as local' to the app, and anything on the server won't be recognized without the correct path as well. things like: <link charset="utf-8" href="https://dl.dropbox.com/u/000000000/leaves/leaves.css" media="screen" rel="stylesheet" type="text/css" /> therefore a generic 'href="./leaves.css" won't work; use a full path. When in doubt, check the file with a 'real' browser, and make sure things show up as expected. With respect to plugins and file updates, if you're going to use the HTMLDoc plugin, you may as well set it to 'no-cache'. It probably won't affect the user much; they'll just reload each time. Cheers! -- Smug
 
puddrix
Apple Fan
Profile
Posts: 16
Reg: Jan 11, 2012
Australia
3,060
like
02/26/15 02:19 PM (9 years ago)
Wow thanks Smug, all totally makes sense and yeah i'd say at it had to be long enough to cover it properly! Your explanation is very much appreciated. Haha keep the 'so's' coming! hmm so I am using HTML Docs and I have about 3 pages i'd like to update/refresh probably once to twice a week each if possible, most of the time once a week. So i guess the question is how do I go about implementing either solution? I don't have my own webspace but I did a bit of digging to see what was a quick/easy solution for the time being without a great deal of luck. A majority appear to be dropbox clones and the couple I tried anyway I'd get the pages of erratic text each time I attempted. So i'm guessing i have to modify the dataURL on the main page to check the config for these updated changes? That is the part i'm a little unsure of actually, well, implementing? I'm sure it's moderately simple but I guess i'm asking what exactly do I modify/implement in the dataURL (assuming it's only the one on the main page of my control panel)? I do understand your explanation but I guess i'm missing the 'starting point'? Thanks ALOT, Dave
 
puddrix
Apple Fan
Profile
Posts: 16
Reg: Jan 11, 2012
Australia
3,060
like
02/26/15 02:26 PM (9 years ago)
Awesome, thanks mate. Ugh i'm not sure why I keep continually posting as I haven't done so so apologies for that.. Great i'll give that a try today, all seems relatively simple :) You've been beyond helpful mate!
 
puddrix
Apple Fan
Profile
Posts: 16
Reg: Jan 11, 2012
Australia
3,060
like
02/28/15 07:29 PM (9 years ago)
Awesome, thanks mate. Ugh i'm not sure why I keep continually posting as I haven't done so so apologies for that.. Great i'll give that a try today, all seems relatively simple :) You've been beyond helpful mate!
 
puddrix
Apple Fan
Profile
Posts: 16
Reg: Jan 11, 2012
Australia
3,060
like
02/28/15 11:55 PM (9 years ago)
Thanks Smug, i've had success! I ended up changing plugins from HTML Doc to just a pdf plugin. Seemed to totally fix the problem. I don't know why this would matter but it's working as it should so i'm happy! Appreciate it mate! I don't know why I keep reposting everything, very annoying
 

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.