Jump to content

Onrecordstart: Suppress multiple graphic fields based on input


Meir

Recommended Posts

I have product that has an option for page size, orientation, and bleed.

 

As of now, my product will suppress all pages that are not the size or orientation selected. However, when I compose my record, regardless of my selection for bleed, the "Bleed" and "NoBleed" graphic box appears.

 

Each page has a two graphic fields on them [bleed, NoBleed].

 

Is the fact that there are multiple graphic frames with the same name an issue? I assume that it should suppress all graphic fields with this name.

 

if (Field("Bleed") == "Yes"){
   FindGraphicFrame("Bleed").suppress = false;
   FindGraphicFrame("NoBleed").suppress = true;
}
else {
   FindGraphicFrame("Bleed").suppress = true;
   FindGraphicFrame("NoBleed").suppress = false;
}


if (Field("Orientation")== "Portrait")
   {

       FusionPro.Composition.SetBodyPageUsage("small_L", false);

       FusionPro.Composition.SetBodyPageUsage("large_L", false);

       if (Field("Size") == '11" x 17"' )
           {

               FusionPro.Composition.SetBodyPageUsage("small_P", false);

               FusionPro.Composition.SetBodyPageUsage("large_P", true);

           }
       else if (Field("Size") == '8.5" x 11"' )
           {


               FusionPro.Composition.SetBodyPageUsage("small_P", true);

               FusionPro.Composition.SetBodyPageUsage("large_P", false);
           }
   }

else if (Field("Orientation")== "Landscape")
    {

       FusionPro.Composition.SetBodyPageUsage("small_P", false);

       FusionPro.Composition.SetBodyPageUsage("large_P", false);

       if (Field("Size") == '11" x 17"' )
           {

               FusionPro.Composition.SetBodyPageUsage("small_L", false);

               FusionPro.Composition.SetBodyPageUsage("large_L", true);

           }
       else if (Field("Size") == '8.5" x 11"' )
           {

               FusionPro.Composition.SetBodyPageUsage("small_L", true);

               FusionPro.Composition.SetBodyPageUsage("large_L", false);
           }
   }

Link to comment
Share on other sites

Is the fact that there are multiple graphic frames with the same name an issue?

Yes.

I assume that it should suppress all graphic fields with this name.

No, the FindGraphicFrame function (like the FindTextFrame function) returns only one frame object. If you have multiple frames with the same name, it will find only one of them.

 

You probably want to come up with some kind of naming scheme using the page numbers, such as "P1_Bleed", "P1_NoBleed", "P2_Bleed", "P2_NoBleed", etc., so that you can deal with them in a loop, something like this:

var useBleed = (Field("Bleed") == "Yes");
var numPages = 2; // change this to the appropriate number for your template
for (var page = 1; page <= numPages; page++)
{
   FindGraphicFrame("P" + page + "_Bleed").suppress = !useBleed;
   FindGraphicFrame("P" + page + "_NoBleed").suppress = useBleed;
}

Although, you could optimize this by suppressing the frames only on the pages you're actually outputting.

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