Jump to content

onNewOutputFile callback is not running during composition


e88z4

Recommended Posts

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.Composition.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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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).split(".");

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

}

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

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.

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