Go Back   MarcomCentral (PTI) and FusionPro User Communities > Software-Related Talk > The JavaScript Library

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old June 1st, 2012, 08:35 AM
e88z4 e88z4 is offline
Forum n00b
 
Join Date: Mar 2011
Posts: 4
Default onNewOutputFile callback is not running during composition

Hi,

I have a simple callback rule for onNewOutputFile

Code:
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

Code:
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?
Reply With Quote
  #2  
Old June 1st, 2012, 10:41 AM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
 
Join Date: Aug 2008
Location: Chicago, IL
Posts: 4,694
Default Re: onNewOutputFile callback is not running during composition

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.
__________________
Dan Korn
FusionPro Developer / JavaScript Guru / Forum Moderator
PTI Marketing Technologies | Printable | MarcomCentral
LinkedIn

I am a not a Support engineer, and this forum is not a substitute for Support. My participation on this forum is primarily as a fellow user (and a forum moderator). I am happy to provide help and answers to questions when I can; however, there is no guarantee that I, or anyone else on this forum, will be able to answer all questions or fix any problems. If I ask for files to clarify an issue, I might not be able to look at them personally. I am not able to answer private messages, emails, or phone calls unless they go through proper Support channels. Please direct any sales or pricing questions to your salesperson or inquiries@marcom.com.

Complex template-building questions, as well as all installation and font questions or problems, should be directed to FusionProSupport@marcom.com. Paid consulting work may be required to fulfill your template-building needs.

This is a publicly viewable forum. Please DO NOT post fonts, or other proprietary content, to this forum. Also, please DO NOT post any "live" data with real names, addresses, or any other personal, private, or confidential data.

Please include the specific versions of FusionPro, Acrobat, and your operating system in any problem reports or help requests. I recommend putting this information in your forum signature. Please also check your composition log (.msg) file for relevant error or warning messages.

Please post questions specific to the MarcomCentral Enterprise and Web-to-Print applications in the MarcomCentral forum. Click here to request access. Or contact your Business Relationship Manager (BRM/CPM) for assistance.

Please direct any questions specific to EFI's Digital StoreFront (DSF) to EFI support.

How To Ask Questions The Smart Way

The correct spellings are JavaScript, FusionPro, and MarcomCentral (each with two capital letters and no spaces). Acceptable abbreviations are JS, FP, and MC (or MCC). There is no "S" at the end of "Expression" or "Printable"! The name of the product is FusionPro, not "Fusion". "Java" is not is not the same as JavaScript.

Check out the JavaScript Guide and JavaScript Reference! FusionPro 8.0 and newer use JavaScript 1.7. Older versions use JavaScript 1.5.

return "KbwbTdsjqu!spdlt\"".replace(/./g,function(w){return String.fromCharCode(w.charCodeAt()-1)});
Reply With Quote
  #3  
Old June 1st, 2012, 11:34 AM
e88z4 e88z4 is offline
Forum n00b
 
Join Date: Mar 2011
Posts: 4
Default Re: onNewOutputFile callback is not running during composition

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?
Reply With Quote
  #4  
Old June 4th, 2012, 10:16 AM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
 
Join Date: Aug 2008
Location: Chicago, IL
Posts: 4,694
Default Re: onNewOutputFile callback is not running during composition

Quote:
Originally Posted by e88z4 View Post
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.
Quote:
Originally Posted by e88z4 View Post
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:
Code:
if (!FusionPro.Composition.isPreview)
{
  // ... code to change the output file name here ...
}
__________________
Dan Korn
FusionPro Developer / JavaScript Guru / Forum Moderator
PTI Marketing Technologies | Printable | MarcomCentral
LinkedIn

I am a not a Support engineer, and this forum is not a substitute for Support. My participation on this forum is primarily as a fellow user (and a forum moderator). I am happy to provide help and answers to questions when I can; however, there is no guarantee that I, or anyone else on this forum, will be able to answer all questions or fix any problems. If I ask for files to clarify an issue, I might not be able to look at them personally. I am not able to answer private messages, emails, or phone calls unless they go through proper Support channels. Please direct any sales or pricing questions to your salesperson or inquiries@marcom.com.

Complex template-building questions, as well as all installation and font questions or problems, should be directed to FusionProSupport@marcom.com. Paid consulting work may be required to fulfill your template-building needs.

This is a publicly viewable forum. Please DO NOT post fonts, or other proprietary content, to this forum. Also, please DO NOT post any "live" data with real names, addresses, or any other personal, private, or confidential data.

Please include the specific versions of FusionPro, Acrobat, and your operating system in any problem reports or help requests. I recommend putting this information in your forum signature. Please also check your composition log (.msg) file for relevant error or warning messages.

Please post questions specific to the MarcomCentral Enterprise and Web-to-Print applications in the MarcomCentral forum. Click here to request access. Or contact your Business Relationship Manager (BRM/CPM) for assistance.

Please direct any questions specific to EFI's Digital StoreFront (DSF) to EFI support.

How To Ask Questions The Smart Way

The correct spellings are JavaScript, FusionPro, and MarcomCentral (each with two capital letters and no spaces). Acceptable abbreviations are JS, FP, and MC (or MCC). There is no "S" at the end of "Expression" or "Printable"! The name of the product is FusionPro, not "Fusion". "Java" is not is not the same as JavaScript.

Check out the JavaScript Guide and JavaScript Reference! FusionPro 8.0 and newer use JavaScript 1.7. Older versions use JavaScript 1.5.

return "KbwbTdsjqu!spdlt\"".replace(/./g,function(w){return String.fromCharCode(w.charCodeAt()-1)});
Reply With Quote
  #5  
Old June 4th, 2012, 02:15 PM
e88z4 e88z4 is offline
Forum n00b
 
Join Date: Mar 2011
Posts: 4
Default Re: onNewOutputFile callback is not running during composition

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

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

}
Reply With Quote
  #6  
Old June 4th, 2012, 02:48 PM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
 
Join Date: Aug 2008
Location: Chicago, IL
Posts: 4,694
Default Re: onNewOutputFile callback is not running during composition

Quote:
Originally Posted by e88z4 View Post
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?
__________________
Dan Korn
FusionPro Developer / JavaScript Guru / Forum Moderator
PTI Marketing Technologies | Printable | MarcomCentral
LinkedIn

I am a not a Support engineer, and this forum is not a substitute for Support. My participation on this forum is primarily as a fellow user (and a forum moderator). I am happy to provide help and answers to questions when I can; however, there is no guarantee that I, or anyone else on this forum, will be able to answer all questions or fix any problems. If I ask for files to clarify an issue, I might not be able to look at them personally. I am not able to answer private messages, emails, or phone calls unless they go through proper Support channels. Please direct any sales or pricing questions to your salesperson or inquiries@marcom.com.

Complex template-building questions, as well as all installation and font questions or problems, should be directed to FusionProSupport@marcom.com. Paid consulting work may be required to fulfill your template-building needs.

This is a publicly viewable forum. Please DO NOT post fonts, or other proprietary content, to this forum. Also, please DO NOT post any "live" data with real names, addresses, or any other personal, private, or confidential data.

Please include the specific versions of FusionPro, Acrobat, and your operating system in any problem reports or help requests. I recommend putting this information in your forum signature. Please also check your composition log (.msg) file for relevant error or warning messages.

Please post questions specific to the MarcomCentral Enterprise and Web-to-Print applications in the MarcomCentral forum. Click here to request access. Or contact your Business Relationship Manager (BRM/CPM) for assistance.

Please direct any questions specific to EFI's Digital StoreFront (DSF) to EFI support.

How To Ask Questions The Smart Way

The correct spellings are JavaScript, FusionPro, and MarcomCentral (each with two capital letters and no spaces). Acceptable abbreviations are JS, FP, and MC (or MCC). There is no "S" at the end of "Expression" or "Printable"! The name of the product is FusionPro, not "Fusion". "Java" is not is not the same as JavaScript.

Check out the JavaScript Guide and JavaScript Reference! FusionPro 8.0 and newer use JavaScript 1.7. Older versions use JavaScript 1.5.

return "KbwbTdsjqu!spdlt\"".replace(/./g,function(w){return String.fromCharCode(w.charCodeAt()-1)});
Reply With Quote
  #7  
Old June 5th, 2012, 07:04 AM
e88z4 e88z4 is offline
Forum n00b
 
Join Date: Mar 2011
Posts: 4
Default Re: onNewOutputFile callback is not running during composition

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.
Reply With Quote
  #8  
Old June 5th, 2012, 09:36 AM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
 
Join Date: Aug 2008
Location: Chicago, IL
Posts: 4,694
Default Re: onNewOutputFile callback is not running during composition

Quote:
Originally Posted by e88z4 View Post
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.
__________________
Dan Korn
FusionPro Developer / JavaScript Guru / Forum Moderator
PTI Marketing Technologies | Printable | MarcomCentral
LinkedIn

I am a not a Support engineer, and this forum is not a substitute for Support. My participation on this forum is primarily as a fellow user (and a forum moderator). I am happy to provide help and answers to questions when I can; however, there is no guarantee that I, or anyone else on this forum, will be able to answer all questions or fix any problems. If I ask for files to clarify an issue, I might not be able to look at them personally. I am not able to answer private messages, emails, or phone calls unless they go through proper Support channels. Please direct any sales or pricing questions to your salesperson or inquiries@marcom.com.

Complex template-building questions, as well as all installation and font questions or problems, should be directed to FusionProSupport@marcom.com. Paid consulting work may be required to fulfill your template-building needs.

This is a publicly viewable forum. Please DO NOT post fonts, or other proprietary content, to this forum. Also, please DO NOT post any "live" data with real names, addresses, or any other personal, private, or confidential data.

Please include the specific versions of FusionPro, Acrobat, and your operating system in any problem reports or help requests. I recommend putting this information in your forum signature. Please also check your composition log (.msg) file for relevant error or warning messages.

Please post questions specific to the MarcomCentral Enterprise and Web-to-Print applications in the MarcomCentral forum. Click here to request access. Or contact your Business Relationship Manager (BRM/CPM) for assistance.

Please direct any questions specific to EFI's Digital StoreFront (DSF) to EFI support.

How To Ask Questions The Smart Way

The correct spellings are JavaScript, FusionPro, and MarcomCentral (each with two capital letters and no spaces). Acceptable abbreviations are JS, FP, and MC (or MCC). There is no "S" at the end of "Expression" or "Printable"! The name of the product is FusionPro, not "Fusion". "Java" is not is not the same as JavaScript.

Check out the JavaScript Guide and JavaScript Reference! FusionPro 8.0 and newer use JavaScript 1.7. Older versions use JavaScript 1.5.

return "KbwbTdsjqu!spdlt\"".replace(/./g,function(w){return String.fromCharCode(w.charCodeAt()-1)});
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 09:30 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2023, Jelsoft Enterprises Ltd.
(c) 2011, PTI Marketing Technologies™, Inc.