kwinsley Posted October 25, 2011 Share Posted October 25, 2011 Hi all, Here's an OnRecordStart question. We have a twenty page PDF that is to represent 10 2-sided signs. That is, page 1 and page 2 are the first sign, front and back. Page 3 and 4 are sign 2, etc. Based upon the field "Version Text 1" through "..10" we want the user to be able to turn on and off pages. I had it working when I was only turning off one page per variable field, but I can't get it to work to turn off two pages. This is where I'm at right now: if (Field("Version Text 1") == "Y") FusionPro.Composition.SetBodyPageUsage("Body1",true); else FusionPro.Composition.SetBodyPageUsage("Body1",false); if (Field("Version Text 1") == "Y") FusionPro.Composition.SetBodyPageUsage("Body2",true); else FusionPro.Composition.SetBodyPageUsage("Body2",false); if (Field("Version Text 2") == "Y") FusionPro.Composition.SetBodyPageUsage("Body3",true); else FusionPro.Composition.SetBodyPageUsage("Body3",false); if (Field("Version Text 2") == "Y") FusionPro.Composition.SetBodyPageUsage("Body4",true); else FusionPro.Composition.SetBodyPageUsage("Body4",false); if (Field("Version Text 3") == "Y") FusionPro.Composition.SetBodyPageUsage("Body5",true); else FusionPro.Composition.SetBodyPageUsage("Body5",false); if (Field("Version Text 3") == "Y") FusionPro.Composition.SetBodyPageUsage("Body6",true); else FusionPro.Composition.SetBodyPageUsage("Body6",false); if (Field("Version Text 4") == "Y") FusionPro.Composition.SetBodyPageUsage("Body7",true); else FusionPro.Composition.SetBodyPageUsage("Body7",false); if (Field("Version Text 4") == "Y") FusionPro.Composition.SetBodyPageUsage("Body8",true); else FusionPro.Composition.SetBodyPageUsage("Body8",false); if (Field("Version Text 5") == "Y") FusionPro.Composition.SetBodyPageUsage("Body9",true); else FusionPro.Composition.SetBodyPageUsage("Body9",false); if (Field("Version Text 5") == "Y") FusionPro.Composition.SetBodyPageUsage("Body10",true); else FusionPro.Composition.SetBodyPageUsage("Body10",false); if (Field("Version Text 6") == "Y") FusionPro.Composition.SetBodyPageUsage("Body11",true); else FusionPro.Composition.SetBodyPageUsage("Body11",false); if (Field("Version Text 6") == "Y") FusionPro.Composition.SetBodyPageUsage("Body12",true); else FusionPro.Composition.SetBodyPageUsage("Body12",false); if (Field("Version Text 7") == "Y") FusionPro.Composition.SetBodyPageUsage("Body13",true); else FusionPro.Composition.SetBodyPageUsage("Body13",false); if (Field("Version Text 7") == "Y") FusionPro.Composition.SetBodyPageUsage("Body14",true); else FusionPro.Composition.SetBodyPageUsage("Body14",false); if (Field("Version Text 8") == "Y") FusionPro.Composition.SetBodyPageUsage("Body15",true); else FusionPro.Composition.SetBodyPageUsage("Body15",false); if (Field("Version Text 8") == "Y") FusionPro.Composition.SetBodyPageUsage("Body16",true); else FusionPro.Composition.SetBodyPageUsage("Body16",false); if (Field("Version Text 9") == "Y") FusionPro.Composition.SetBodyPageUsage("Body17",true); else FusionPro.Composition.SetBodyPageUsage("Body17",false); if (Field("Version Text 9") == "Y") FusionPro.Composition.SetBodyPageUsage("Body18",true); else FusionPro.Composition.SetBodyPageUsage("Body18",false); if (Field("Version Text 10") == "Y") FusionPro.Composition.SetBodyPageUsage("Body19",true); else FusionPro.Composition.SetBodyPageUsage("Body19",false); if (Field("Version Text 10") == "Y") FusionPro.Composition.SetBodyPageUsage("Body20",true); else FusionPro.Composition.SetBodyPageUsage("Body20",false); Where is the code wrong, and is there an easier way to do this? I'm building it in Acrobat 9.0.0 / FP 7.1P1c on a Windows 7 machine. Thanks all! Link to comment Share on other sites More sharing options...
kwinsley Posted October 25, 2011 Author Share Posted October 25, 2011 Never mind. I guess the title "n00b" is appropriate. If you're going to call a page by a name in a rule, make sure it is named in Page Usage. Different names don't work either... But, part of the question still remains. Is there a better, more concise way to write this rule? Link to comment Share on other sites More sharing options...
Dan Korn Posted October 25, 2011 Share Posted October 25, 2011 But, part of the question still remains. Is there a better, more concise way to write this rule? Sure, you can use a for loop, like so: for (var i = 1; i <= 10; i++) { var activate = Field("Version Text " + i) == "Y"; FusionPro.Composition.SetBodyPageUsage("Body" + ((i * 2) - 1), activate); FusionPro.Composition.SetBodyPageUsage("Body" + (i * 2), activate); } Link to comment Share on other sites More sharing options...
kwinsley Posted October 25, 2011 Author Share Posted October 25, 2011 Dan, That's a lot easier and more flexible too. Thank you very much! Kurt Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.