Jump to content

Static text not bring recognized in OnNewOutputFile


Recommended Posts

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";

Link to comment
Share on other sites

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);

Also, 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.Composition.inputFileName), "pdf");

Link to comment
Share on other sites

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.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...