Pierhouse Posted November 3, 2008 Share Posted November 3, 2008 (edited) When creating my output PDF file I am wanting the output file name to be based upon the name of the seletcted input data file. For example: Selected data input file name: Std4_0310.txt Desired PDF output file name: Std4_0310.pdf I have tried to acheive this using the following OnNewOtputFile rule: FusionPro.Composition.OutputFileName = FusionPro.Composition.InputFileName The rule validates ok but I'm obviously doing something wrong as it still creates the output file with the name designated within the Compose Template-Output-Ouput Filename section. Any ideas would be greatly appreciated. G Edited November 3, 2008 by Pierhouse Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted November 3, 2008 Share Posted November 3, 2008 Create the OnNewOutputFile callback rule, and do something like this: FusionPro.Composition.outputFileName = FusionPro.Composition.inputFileName + ".pdf"; Quote Link to comment Share on other sites More sharing options...
Jordanh Posted November 3, 2008 Share Posted November 3, 2008 When you create that rule, where exactly do you place it? I know with text rules you make a variable text frame and place the rule into it. But where do you put the rules that configure the output files? Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted November 3, 2008 Share Posted November 3, 2008 Callback rules do not need to be placed into text frames. Actually, they can't be used that way. They're different than regular rules which return a value for composition. Instead, they're hooks into specific composition-time functionality. The complete list of callback rules is: OnJobStartOnJobEndOnRecordStartOnRecordEndOnNewOutputFileOnCopyfitTo create them, click on "New" in the Rules dialog, then select the "Callback" radio button. Quote Link to comment Share on other sites More sharing options...
Pierhouse Posted November 4, 2008 Author Share Posted November 4, 2008 Thanks Dan. I can now see the error of my ways. I didn't realise that the "inputFileName" and "outputFileName" parts are case sensitive. The only thing is that when using that rule my preview no longer works for some reason. As soon as I remove the rule the preview works. Any ideas?? Cheers G Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted November 4, 2008 Share Posted November 4, 2008 Thanks Dan. I can now see the error of my ways. I didn't realise that the "inputFileName" and "outputFileName" parts are case sensitive. Yes, property names in JavaScript are case-sensitive. The file names may also be case-sensitive, depending on the operating system. (Mac is case-sensitive, while Windows is generally not, although some shared network drives may be case-sensitive even when mounted on Windows.) The only thing is that when using that rule my preview no longer works for some reason. As soon as I remove the rule the preview works. Any ideas?? Can you be more precise about the failure mode? In exactly what way does Preview not work? Quote Link to comment Share on other sites More sharing options...
Pierhouse Posted November 5, 2008 Author Share Posted November 5, 2008 Sorry, the preview no longer works in as much as when I click the preview button in the Preview pane the screen refreshes, automatically deselects the tick in the preview button but does not preview anything. G Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted November 5, 2008 Share Posted November 5, 2008 Sorry, the preview no longer works in as much as when I click the preview button in the Preview pane the screen refreshes, automatically deselects the tick in the preview button but does not preview anything. Ah, sorry, that's a bug. The workaround is to use the FusionPro.Composition.isPreview property to disable the output file rename for Preview. For example: if (!FusionPro.Composition.isPreview) FusionPro.Composition.outputFileName = FusionPro.Composition.inputFileName + ".pdf"; This is on our list of issues to address. Please reference case FP-11072. Quote Link to comment Share on other sites More sharing options...
Pierhouse Posted November 6, 2008 Author Share Posted November 6, 2008 (edited) Thanks yet again Dan for your help. I'm sure it me just being stupid but I'm unable to find the case you refer to (FP-11072) Where are all the recorded cases held? G Edited November 6, 2008 by Pierhouse Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted November 6, 2008 Share Posted November 6, 2008 I'm unable to find the case you refer to (FP-11072) Where are all the recorded cases held? That's a case number in our internal defect-tracking system. It's not generally accessible to customers. But you can reference that case number in any subsequent inquiries about the issue, so that we can track it. Quote Link to comment Share on other sites More sharing options...
Pierhouse Posted November 7, 2008 Author Share Posted November 7, 2008 Oh I see, will do. Thanks Dan. G Quote Link to comment Share on other sites More sharing options...
Pierhouse Posted November 7, 2008 Author Share Posted November 7, 2008 Oh I see. No worries will do. Thanks again for all your help. G Quote Link to comment Share on other sites More sharing options...
chads Posted November 20, 2008 Share Posted November 20, 2008 Ah, sorry, that's a bug. The workaround is to use the FusionPro.Composition.isPreview property to disable the output file rename for Preview. For example: if (!FusionPro.Composition.isPreview) FusionPro.Composition.outputFileName = FusionPro.Composition.inputFileName + ".pdf";This is on our list of issues to address. Please reference case FP-11072. This is great, but is there a way to trim the file extension of the input file? For instance myinputfile.csv.pdf to be myinputfile.pdf? Quote Link to comment Share on other sites More sharing options...
Pierhouse Posted November 21, 2008 Author Share Posted November 21, 2008 Hi Chad Create a Rule of type Callback and select OnNewOuputFile. This rule will then be called when a new output file is about to be opened. Use the below code within the rule to create the output filename using the input file name, stripping off the extention and adding .pdf. PDFName = FusionPro.Composition.inputFileName; FullName = PDFName.split("."); FileName = FullName[0]; FileExt = FullName[1]; FusionPro.Composition.outputFileName = FileName + ".pdf" Hope this helps G Quote Link to comment Share on other sites More sharing options...
DSweet Posted November 21, 2008 Share Posted November 21, 2008 Chad, I've used this in the OnJobStart callback rule to get the incoming file name. You could then store it off to a variable and call it when you do your output file creation as in the rule mentioned in the above postings. This was done on a PC so if you need a Mac version simply put in the correct string to look for in the lastIndex rule. inFile = ToLower(FusionPro.Composition.inputFileName); var i = inFile.lastIndexOf("\\"); myInputFile = Mid(inFile, i+2, (inFile.length - i)); replaceCheck1 = ReplaceSubstring(myInputFile, ".csv", ""); finalFileName = ReplaceSubstring(replaceCheck1, ".txt", ""); This will give you the finalFileName value of instance file that you are using for your composition but without any extension. I don't know if you normally use a "csv" or a "txt" file for your data, but you should leave both in there to remove either case. Again if you're on a Mac you do need to watch out for those few programmers that like to use dots within the middle of filenames since that string might appear twice. Good Luck Quote Link to comment Share on other sites More sharing options...
ehigginbotham Posted August 17, 2012 Share Posted August 17, 2012 any ideas why I would be getting "R:\70948-J and 70949-K\FP data\J240B.TXT.pdf" as my name, when my input name is "J 240 B_.TXT"?? I've never tried it off of the input name, but I've had success using static text + fields. I tried taking the spaces and underscore out of my original data name, but no success. Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted August 17, 2012 Share Posted August 17, 2012 any ideas why I would be getting "R:\70948-J and 70949-K\FP data\J240B.TXT.pdf" as my name, when my input name is "J 240 B_.TXT"?? I've never tried it off of the input name, but I've had success using static text + fields. I tried taking the spaces and underscore out of my original data name, but no success. What JavaScript logic are you using which gives those results? I would just do this: if (!FusionPro.Composition.isPreview) FusionPro.Composition.outputFileName = ReplaceFileExtension(GetFileName(FusionPro.Composition.inputFileName), FusionPro.Composition.outputFormatExtension); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.