Jump to content

if statement in a config file


Recommended Posts

Can a config file contain an if statement? I have a template that needs to have two different imposition layouts based on the state code within a data file.


Can I combine the two imposition calls into one statement such as:

if (Field("state1") == "FL")  {
else  {

Just trying to make it a bit easier for our webProgrammer.


I know that I can pass a parameter from the .cfg file to the Template, so can this be accomplished in reverse -- passing a parameter from the Template (i.e. a field value) to the .cfg file then use that data value in a conditional statement within it. If this is not the way to pass parameters from the template to the config file then how do we?


Link to comment
Share on other sites

No, you can't do this. At the point that JavaScript rules are run, the CFG file has already been read. In fact, one of the things that is read from the CFG file is the path to the Data Definition (.def) file which contains the JavaScript rules. Therefore, the JavaScript rules in the template can only access the CFG file entries; they can't modify them. That said, some composition parameters (like the output file) can be modified with the FusionPro.Composition object in certain callbacks, but the imposition template (FPI file) is not one of them.


This is something you would need to do with the FusionPro VDP Producer Web Service API (or by directly modifying the CFG file) in your web application's code, not in JavaScript in the FusionPro template itself. A C# example using the Web Service would look something like this:

CompositionRequest request = new CompositionRequest();
request.TemplateName = "YourTemplateName";
request.Options = new JobOptions();
request.Options.OutputFormat = OutputFormat.PDF;
request.Options.UseImposition = true;

string ErrorMessage = "";
int CompositionID = myFPWcfService.CreateCompositionSession(out ErrorMessage, request);
if (!String.IsNullOrEmpty(ErrorMessage))
   return "Failed to create composition session: " + ErrorMessage;

ErrorMessage = myFPWcfService.AddCompositionFile(CompositionID, FileType.Imposition, "gedcRXpadFinal_Florida.fpi");
if (!String.IsNullOrEmpty(ErrorMessage))
   return "Failed to add imposition file for composition " + CompositionID + ": " + ErrorMessage;

ErrorMessage = myFPWcfService.StartCompositionFromSession(CompositionID);

Link to comment
Share on other sites


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

  • Create New...