MarcomCentral (PTI) and FusionPro User Communities

MarcomCentral (PTI) and FusionPro User Communities (http://forums.pti.com/index.php)
-   The JavaScript Library (http://forums.pti.com/forumdisplay.php?f=23)
-   -   OnRecordStart - turn off PDF pages. (http://forums.pti.com/showthread.php?t=2520)

kwinsley October 25th, 2011 02:01 PM

OnRecordStart - turn off PDF pages.
 
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:

Code:

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!

kwinsley October 25th, 2011 02:16 PM

Re: OnRecordStart - turn off PDF pages.
 
Never mind. I guess the title "n00b" is appropriate.:rolleyes:

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

But, part of the question still remains. Is there a better, more concise way to write this rule?

Dan Korn October 25th, 2011 02:44 PM

Re: OnRecordStart - turn off PDF pages.
 
Quote:

Originally Posted by kwinsley (Post 9060)
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:
Code:

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


kwinsley October 25th, 2011 02:50 PM

Re: OnRecordStart - turn off PDF pages.
 
Dan,

That's a lot easier and more flexible too. Thank you very much!

Kurt


All times are GMT -7. The time now is 04:17 AM.

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