PDA

View Full Version : Static text not bring recognized in OnNewOutputFile


step
April 23rd, 2012, 08:04 AM
I have the following code in which I'm attempting to name the output file as "internal job number" + "client's csv file name" + ".pdf" extension.

And for some reason the result is just the "client's csv file name + the .pdf extension disregarding the static text prefix.

Is this a known issue with 7.2? I have had success doing this in the past before upgrading. Any ideas?


var input = FusionPro.Composition.inputFileName;
var file = input.split(".");
FusionPro.Composition.outputFileName = "143340-1_" + file[0] + ".pdf";

Dan Korn
April 23rd, 2012, 08:34 AM
FusionPro.Composition.inputFileName returns the full path of the input file, which starts with a slash on Mac. You're effectively telling it to look for a file like "143340-1_/some path on your Mac/filename.pdf", which of course doesn't exist. So it ignores the path and just uses the file name. You want to use the GetFileName function to strip off the path, like so:
var input = GetFileName(FusionPro.Composition.inputFileName);A lso, the way you're removing the extension from the file name won't properly handle the case where the name contains more than one dot (like "joe.smith.txt"). You can use the ReplaceFileExtension function instead to handle this. So the rule then becomes:
FusionPro.Composition.outputFileName = "143340-1_" +
ReplaceFileExtension(GetFileName(FusionPro.Composi tion.inputFileName), "pdf");

step
April 23rd, 2012, 08:40 AM
Excellent! Thanks for the quick reply, Dan!