Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 6    Views: 29

Sherry
Lost but trying
Profile
Posts: 135
Reg: Jan 05, 2013
South Africa
11,650
06/14/15 03:26 PM (9 years ago)

Changed PDF filenames when document are emailed

I have an app with all the pdf document locations as URLs but when the user emails the documents to themselves the pdf filename that gets sent is different to what is on the server and my client keeps asking if I can change this. I saw a thread from 2 years ago but it was for BT 2.0 and not sure if it is still applicable or if there is an easier way to fix this. http://www.buzztouch.com/forum/thread.php?tid=1EA51E646F89719BDE38A2B&currentPage=1
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
06/14/15 05:54 PM (9 years ago)
What is the original filename, and what is the filename being used by the email? Is it a 'consistent' mis-name? Something we can parse the real filename from before it gets to the email? Cheers! -- Smug
 
Sherry
Lost but trying
Profile
Posts: 135
Reg: Jan 05, 2013
South Africa
11,650
like
06/15/15 03:28 PM (9 years ago)
Thanks Smug for your assistance the original file name loaded on the control panel in document location is http://file location on server/documents/aliette_wg_label.pdf but instead of the user getting a file named alliette_wg_label.pdf which is the product name the user is getting a file name that looks like this: aa1edea8770e66ac667e578_screenData.pdf
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
06/16/15 06:38 AM (9 years ago)
Are you using this with the PDF viewer plugin? I haven't tried this, so it will require a little testing on your part. But, if we were to (only in the plugin) change the naming of the 'saveAsFilename' from 'appGuid + screenData + file extension' to the actual filename. Fingers crossed, this is how I would try it: On line 79 of my BT_screen_pdfDoc.m file is this line: [self setSaveAsFileName:[NSString stringWithFormat:@"%@_screenData.pdf", [self.screenData itemId]]]; pre-pend that line with this: NSString *url = [BT_strings getJsonPropertyValue:self.screenData.jsonVars nameOfProperty:@"dataURL" defaultValue:@""]; NSArray *parts = [url componentsSeparatedByString:@"/"]; NSString *myFilename = [parts lastObject]; and then change the line to something like this: [self setSaveAsFileName:myFilename]; and see how that works. Don't release this without testing first... And let me know how it goes. Cheers! -- Smug
 
Sherry
Lost but trying
Profile
Posts: 135
Reg: Jan 05, 2013
South Africa
11,650
like
09/25/15 12:02 PM (8 years ago)
Hi Smug I finally had a chance to test this because I'm working on new apps due for release this next week and it works PERFECTLY thanks so much. Please can you give me the same type of code for Android :) I'm using the same std pdf plugin on Android. Sherry
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
09/26/15 09:28 AM (8 years ago)
// add this line up top... import org.apache.commons.io.FilenameUtils; // around line 122 you have this line: saveAsFileName = this.screenData.getItemId() + "_screenData.pdf"; comment that out and add this code: String baseName = FilenameUtils.getBaseName(dataURL); String extension = FilenameUtils.getExtension(dataURL); saveAsFileName = baseName + "." + extension; Cheers! -- Smug
 
Sherry
Lost but trying
Profile
Posts: 135
Reg: Jan 05, 2013
South Africa
11,650
like
09/26/15 01:01 PM (8 years ago)
Thanks Smug YOU'RE THE BEST!! at first it didn't work and gave an error then I found this post below on StackOverflow and voila it now works perfectly :) For Android Studio: File -> Project Structure... -> Dependencies Click '+' in the upper right corner and select "Library dependency" In the search field type: "org.apache.commons.io" and click Search Select "org.apache.directory.studio:org.apache.commons.io:
 

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.