Jump to content

Use Input Date File Name For Output File Name


Pierhouse

Recommended Posts

Posted

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

:)

Posted
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?
Posted

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:

  • OnJobStart
  • OnJobEnd
  • OnRecordStart
  • OnRecordEnd
  • OnNewOutputFile
  • OnCopyfit

To create them, click on "New" in the Rules dialog, then select the "Callback" radio button.

Posted

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

Posted
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?

Posted

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

Posted
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.

Posted

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

Posted
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.

  • 2 weeks later...
Posted
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?

Posted

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

Posted

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

  • 3 years later...
Posted

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.

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...