PDA

View Full Version : onNewOutputFile callback is not running during composition


e88z4
June 1st, 2012, 07:35 AM
Hi,

I have a simple callback rule for onNewOutputFile

newFileExt = FusionPro.Composition.JobOptions["OutputFormat"];

switch (newFileExt){

case "Indigo PPML":
newFileExt = ToLower("." + "PPML");
break;

case "PostScript":
newFileExt = ToLower("." + "ps");
break;

case "Digimaster":
newFileExt = ToLower("." + "ps");
break;

case "Single-File VPS":
newFileExt = ToLower("." + "vps");
break;

case "Multi-File VPS":
newFileExt = ToLower("." + "vps");
break;

case "PDF":
newFileExt = ToLower("." + "pdf");
break;

default:
newFileExt = ToLower("." + newFileExt);
break;

}

FusionPro.Composition.outputFileName = ReplaceFileExtension(GetFileName(FusionPro.Composi tion.inputFileName), newFileExt);

Print("Replacing the output filename with the input filename:");
Print("Input file name is " + GetFileName(FusionPro.Composition.inputFileName));
Print("Output filename is " + FusionPro.Composition.outputFileName);The callback doesn't even run the print statement at the bottom of the code. This rule runs fine with FusionPro 7.1.

I tried to experiment just putting a simple print function in onNewOutputFile

Print("Hello world!");The composition doesn't log the print statement in my log file.

My other solution is put my code in onJobStart but it gives me an error when I try to preview my pdf.

Can you explain the changes from 7.1 to 7.2?

Dan Korn
June 1st, 2012, 09:41 AM
OnNewOutputFile gets called only when a new output file (chunk) is being created. Do you have the "Output to multiple files" box checked on the Output tab of the Composition Settings dialog?

Also, FusionPro 8 introduces arbitrary chunking, where you can open up a new output file at any time, and give the file a name, all in a single call to FusionPro.Composition.OpenNewOutputFile. It also includes a new FusionPro.Composition.outputFormatExtension property which could replace the entire switch statement in your rule.

e88z4
June 1st, 2012, 10:34 AM
I don't have output to multiple files selected because the data is split into several files already.
Can you explain about the preview error I got when I place my code in onJobStart?

Dan Korn
June 4th, 2012, 09:16 AM
I don't have output to multiple files selected because the data is split into several files already.
Sorry, but I don't understand what you mean by that. How are these "several files" of data being processed in the composition?

In any case, the code you posted works fine for me in 7.1, 7.2, and 8.0.
Can you explain about the preview error I got when I place my code in onJobStart?
Changing the output file name confuses Preview, which creates an output file with a specific name in the TEMP folder and then attempts to open it from there. You should wrap all the code which changes the output file name in a block like this:
if (!FusionPro.Composition.isPreview)
{
// ... code to change the output file name here ...
}

e88z4
June 4th, 2012, 01:15 PM
I did you suggestion to use the FusionPro.Composition.IsPreview on onJobStart callback but I got an error when I try previewing my job. I thought that would solve my problem. I am thinking another way to do it by putting the code in onNewOutputFile and click to split file with some huge number bigger than the number of record in the file. I didnd't test it yet.

This is my code below

if(!FusionPro.Composition.IsPreview){
newFileExt = FusionPro.Composition.JobOptions["OutputFormat"];
inputFileName = GetFileName(FusionPro.Composition.inputFileName).s plit(".");

switch (newFileExt){

case "Indigo PPML":
newFileExt = ToLower("." + "PPML");
break;

case "PostScript":
newFileExt = ToLower("." + "ps");
break;

case "Digimaster":
newFileExt = ToLower("." + "ps");
break;

case "Single-File VPS":
newFileExt = ToLower("." + "vps");
break;

case "Multi-File VPS":
newFileExt = ToLower("." + "vps");
break;

case "PDF":
newFileExt = ToLower("." + "pdf");
break;

default:
newFileExt = ToLower("." + newFileExt);
break;

}

FusionPro.Composition.outputFileName = ReplaceFileExtension(GetFileName(inputFileName[0]), newFileExt);

}

Dan Korn
June 4th, 2012, 01:48 PM
I did you suggestion to use the FusionPro.Composition.IsPreview on onJobStart callback but I got an error when I try previewing my job.
Sorry, it seems that I'm not very good at guessing exactly what error you got. Can you be more specific?

e88z4
June 5th, 2012, 06:04 AM
When I use the checkbox to enable my preview to turn my preview on, the checkbox is flickering on and turn back off in less than 1 sec. I don't get my preview.
Another occasion, I got an error box pop-up on the screen telling about some temporary file. I didn't catch the screen capture on that moment. I checked the temporary file, it was a file that FusionPro created to displaying the live preview on screen.

Dan Korn
June 5th, 2012, 08:36 AM
When I use the checkbox to enable my preview to turn my preview on, the checkbox is flickering on and turn back off in less than 1 sec. I don't get my preview.
Another occasion, I got an error box pop-up on the screen telling about some temporary file. I didn't catch the screen capture on that moment. I checked the temporary file, it was a file that FusionPro created to displaying the live preview on screen.
That sounds like you still have some code which changes the output file name which is not guarded by "if (!FusionPro.Composition.IsPreview)", possibly in more than one rule. Please double-check all your rules, remove all the code which modifies the output file name, and try to Preview again. Then add the output file modification code back in, in one rule only, with that "if" statement around all of it.