MarcomCentral (PTI) and FusionPro User Communities

MarcomCentral (PTI) and FusionPro User Communities (http://forums.pti.com/index.php)
-   Digital Workflow Documents (http://forums.pti.com/forumdisplay.php?f=41)
-   -   I'm Having Trouble Page Usage if/then problem (http://forums.pti.com/showthread.php?t=4946)

CCS_Printing August 1st, 2017 08:29 AM

Page Usage if/then problem
 
Acrobat 10
Fusion 9.3.15
Mac OS 10.11.6

I'm using FusionPro.Compositio.SetBodyPageUsage in combination with FusionProResource to use or not use a page and call back a resource if used.
I also have an array to make each section even and then make the complete document divisible by 4. ( which works great ) My problem is I need a pretty simple rule to use a particular page only if one or more of a range of variables are used-otherwise it remains not used. (which I can do -- But it breaks my array for each section being even and the complete document divisible by 4)

Here is my OnRecordStart

For setpageusage and array

Code:

if (Field("Opt1") != "")
    {
    FusionPro.Composition.SetBodyPageUsage("How Plan works at renewal 042821", "true");
    }
if (Field("Opt2") != "")
    {
    FusionPro.Composition.SetBodyPageUsage("HSA w_CYC 042825", "true");
    }
if (Field("Opt3") != "")
    {
    FusionPro.Composition.SetBodyPageUsage("HSA_wo_CYC 042826", "true");
    }
if (Field("Opt4") != "")
    {
    FusionPro.Composition.SetBodyPageUsage("Highlights- EasyChoice A 042531", "true");
    }
if (Field("Filler1") != "")
    {
    FusionPro.Composition.SetBodyPageUsage("Filler1_042861", "true");
    }
if (Field("Filler2") != "")
    {
    FusionPro.Composition.SetBodyPageUsage("Filler2_042862", "true");
    }
if (Field("Filler3") != "")
    {
    FusionPro.Composition.SetBodyPageUsage("Filler3_042863", "true");
    }
if (Field("Opt5") != "")
    {
    FusionPro.Composition.SetBodyPageUsage("Highlights- EasyChoice B 042532", "true");
    }
if (Field("Opt6") != "")
    {
    FusionPro.Composition.SetBodyPageUsage("Highlights-Basic 042533", "true");
    }
if (Field("Opt7") != "")
    {
    FusionPro.Composition.SetBodyPageUsage("Highlights-Plan 2 042536", "true");
    }
if (Field("Opt8") != "")
    {
    FusionPro.Composition.SetBodyPageUsage("Highlights-Plan 3 042537", "true");
    }
if (Field("Opt9") != "")
    {
    FusionPro.Composition.SetBodyPageUsage("Highlights-Plan 5 042535", "true");
    }
if (Field("Opt10") != "")
    {
    FusionPro.Composition.SetBodyPageUsage("Highlights-Plan QDHP 042534", "true");
    }
if (Field("Opt11") != "")
    {
    FusionPro.Composition.SetBodyPageUsage("Highlights-Beffore Enrolling in QDHP 042827", "true");
    }
if (Field("Opt12") != "")
    {
    FusionPro.Composition.SetBodyPageUsage("Dental Plan divider page 042822", "true");
    }
if (Field("Opt13") != "")
    {
    FusionPro.Composition.SetBodyPageUsage("Dental Plan A 042543", "true");
    }
if (Field("Opt14") != "")
    {
    FusionPro.Composition.SetBodyPageUsage("Dental Plan B 042544", "true");
    }
if (Field("Opt15") != "")
    {
    FusionPro.Composition.SetBodyPageUsage("Dental Plan C 042545", "true");
    }
if (Field("Opt16") != "")
    {
    FusionPro.Composition.SetBodyPageUsage("Dental Plan PPO 042547", "true");
    }
if (Field("Opt17") != "")
    {
    FusionPro.Composition.SetBodyPageUsage("Ortho Plan A 042802", "true");
    }
if (Field("Opt18") != "")
    {
    FusionPro.Composition.SetBodyPageUsage("Ortho Plan B 042803", "true");
    }
if (Field("Opt19") != "")
    {
    FusionPro.Composition.SetBodyPageUsage("Ortho Plan C 042804", "true");
    }
if (Field("Opt20") != "")
    {
    FusionPro.Composition.SetBodyPageUsage("Ortho Plan D 042805", "true");
    }
if (Field("Opt21") != "")
    {
    FusionPro.Composition.SetBodyPageUsage("Ortho Plan E 042806", "true");
    }
if (Field("Opt22") != "")
    {
    FusionPro.Composition.SetBodyPageUsage("Ortho Plan F 042807", "true");
    }
if (Field("Opt23") != "")
    {
    FusionPro.Composition.SetBodyPageUsage("Ortho Plan G 042808", "true");
    }
if (Field("Opt24") != "")
    {
    FusionPro.Composition.SetBodyPageUsage("Ortho Plan H 042809", "true");
    }
if (Field("Opt25") != "")
    {
    FusionPro.Composition.SetBodyPageUsage("Ortho Plan I 042810", "true");
    }
if (Field("Opt26") != "")
    {
    FusionPro.Composition.SetBodyPageUsage("Vision Plan divider page 042823", "true");
    }
if (Field("Opt27") != "")
    {
    FusionPro.Composition.SetBodyPageUsage("Vision Plan A 042538", "true");
    }
if (Field("Opt28") != "")
    {
    FusionPro.Composition.SetBodyPageUsage("Vision Plan B 042539", "true");
    }
if (Field("Opt29") != "")
    {
    FusionPro.Composition.SetBodyPageUsage("Vision Plan C 042540", "true");
    }
if (Field("Opt30") != "")
    {
    FusionPro.Composition.SetBodyPageUsage("Vision Plan D 042546", "true");
    }
if (Field("Opt31") != "")
    {
    FusionPro.Composition.SetBodyPageUsage("Vision Plan E 042541", "true");
    }
if (Field("Opt32") != "")
    {
    FusionPro.Composition.SetBodyPageUsage("Vision Plan F 042542", "true");
    }
if (Field("Opt33") != "")
    {
    FusionPro.Composition.SetBodyPageUsage("App ******* Only 042669", "true");
    }
if (Field("Opt34") != "")
    {
    FusionPro.Composition.SetBodyPageUsage("App ******* and Vision 042668", "true");
    }
if (Field("Opt35") != "")
    {
    FusionPro.Composition.SetBodyPageUsage("App ******* and Dental 042824", "true");
    }
if (Field("Opt36") != "")
    {
    FusionPro.Composition.SetBodyPageUsage("App ******* Dental and Vision 042641", "true");
    }
   
   
   
   
   
    var pages = 21; // Number of static pages
var endPages = ['Filler3_042863','Notes Filler Page']; // Names of the Filler Pages at the end

// there are four sections this is whether each section
// should be odd or even
var mustBeEven = [true,false];

// Sections (Named in accordance to their "filler" page)
sections = {
    'Filler1_042861': [
        Field("Opt1"),
        Field("Opt2"),
        Field("Opt3"),
     
       
    ],
    'Filler2_042862': [
        Field("Opt4"),
        Field("Opt5"),
        Field("Opt6"),
        Field("Opt7"),
        Field("Opt8"),
        Field("Opt9"),
        Field("Opt10"),
        Field("Opt11"),
        Field("Opt12"),
        Field("Opt13"),
        Field("Opt14"),
        Field("Opt15"),
        Field("Opt16"),
        Field("Opt17"),
        Field("Opt18"),
        Field("Opt19"),
        Field("Opt20"),
        Field("Opt21"),
        Field("Opt22"),
        Field("Opt23"),
        Field("Opt24"),
        Field("Opt25"),
        Field("Opt26"),
        Field("Opt27"),
        Field("Opt28"),
        Field("Opt29"),
        Field("Opt30"),
        Field("Opt31"),
        Field("Opt32"),
        Field("Opt33"),
        Field("Opt34"),
        Field("Opt35"),
        Field("Opt36"),


    ],

};


var isEven = function (number) {
    return number % 2 === 0;
};

var currentSection = 0;
var i;
var pgCount;
for (i in sections) {
    pgCount = 0;
    sections[i].filter(String).forEach(function(s){   
        pgCount += CreateResource(s, 'graphic').countPages;
    });
    pages += pgCount;
   
    Print("Section processed pages " + i);
    Print(pgCount);
   
   
   
    var addPage = mustBeEven[currentSection] && !isEven(pgCount);
    addPage = addPage || (!mustBeEven[currentSection] && isEven(pgCount));
   
    if (addPage) {
   
            FusionPro.Composition.SetBodyPageUsage(i, pages++);
    }
   
    currentSection++;
}


Print("pages:");
Print(pages);

var pagesNeeded = 4 - ((pages % 4) || 4);

Print("pagesNeeded");
Print(pagesNeeded);

var pagesAdded = 0;

while (pagesNeeded--){

    FusionPro.Composition.SetBodyPageUsage(endPages[pagesNeeded%2], true);
    pagesAdded++;
   

}

Print("pagesAdded");
Print(pagesAdded);

Here is an example of the graphic call back rule

Code:

var Pic = new FusionProResource(Field("Opt12"), "graphic", "true");



if (Field("Opt12") != "")
            {

                return Pic
                            }

Any help would be greatly appreciated

Dan Korn August 1st, 2017 01:45 PM

Re: Page Usage if/then problem
 
This is too hard to try to sort through in the abstract, without having the template files.


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

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