Pierhouse Posted November 3, 2008 Posted November 3, 2008 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
Dan Korn Posted November 3, 2008 Posted November 3, 2008 Create the OnNewOutputFile callback rule, and do something like this: FusionPro.Composition.outputFileName = FusionPro.Composition.inputFileName + ".pdf";
Jordanh Posted November 3, 2008 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?
Dan Korn Posted November 3, 2008 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.
Pierhouse Posted November 4, 2008 Author 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
Dan Korn Posted November 4, 2008 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?
Pierhouse Posted November 5, 2008 Author 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
Dan Korn Posted November 5, 2008 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.
Pierhouse Posted November 6, 2008 Author Posted November 6, 2008 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
Dan Korn Posted November 6, 2008 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.
Pierhouse Posted November 7, 2008 Author Posted November 7, 2008 Oh I see. No worries will do. Thanks again for all your help. G
chads Posted November 20, 2008 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?
Pierhouse Posted November 21, 2008 Author 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
DSweet Posted November 21, 2008 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
ehigginbotham Posted August 17, 2012 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.
Dan Korn Posted August 17, 2012 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);
Recommended Posts
Archived
This topic is now archived and is closed to further replies.