mclisa81 Posted February 10, 2010 Share Posted February 10, 2010 I have an unused body page that should either print or not print based on whether it falls on an even or odd page. The 70 pages in front of it are variable, so the count is always different. If the unused body page falls on an even page, it should print. If it is odd, it should not print. I'll attach an example. Thanks in advance. Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted February 10, 2010 Share Posted February 10, 2010 What determines how many pages are included before the page in question? In other words, the answer to how to control whether to include your page depends on how the other pages are being added. If you're using Overflow pages, you can control how the last page is inserted in the Overflow Options dialog, by setting "Add pages" to "So Last Added Page Is Odd." If you're doing something like inserting pages from an external PDF as in this thread, you will have to key off of the page counter variable in your rule. Quote Link to comment Share on other sites More sharing options...
mclisa81 Posted February 10, 2010 Author Share Posted February 10, 2010 No overflow pages used. I have 71 body pages set to unused in my template. They are turned on based on the funds the client has in their data using the following rule.. var TotalFields = 71; var PrintVersions = new Array(); for (i = 0;i < TotalFields;i++) { if (Field(i+1) != "") { PrintVersions[i] = Field(i+1); } } for (n = 0;n < PrintVersions.length;n++) { var Front1 = PrintVersions[n] + "-front1"; FusionPro.Composition.SetBodyPageUsage(Front1,true); } } So there could be 1-71 pages that are set to "true", and when the last page is an "odd" number of pages, I need the "BlankBack" set to "true", so it backs up the last page (if odd). Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted February 10, 2010 Share Posted February 10, 2010 It seems to me that the value of PrintVersions.length is either going to be true or false, so you should be able to just key off of that, by doing this at the end of the rule: FusionPro.Composition.SetBodyPageUsage("YourPageName", PrintVersions.length % 2);The modulus 2 (% 2) operator will return either 1 (true) or 0 (false) depending on whether the value of the first operand is odd or even. Quote Link to comment Share on other sites More sharing options...
mclisa81 Posted February 11, 2010 Author Share Posted February 11, 2010 Your suggestion worked perfectly, as usual. Thanks Dan! Quote Link to comment Share on other sites More sharing options...
mclisa81 Posted July 21, 2011 Author Share Posted July 21, 2011 Dan, I need to modify this rule that you helped me with last year. Instead of just needing it to be an even page count, we have turned it into a saddlestitch book so in the end, the page count needs to be divisible x4. Is there a way to modify this existing rule to incorporate this change? var TotalFields = 67; var PrintVersions = new Array(); // Populate array with all versions printing in current record for (i = 0;i < TotalFields;i++) { if (Field(i+1) != "") { PrintVersions[i] = Field(i+1); } } // Set which pages print for current record for (n = 0;n < PrintVersions.length;n++) { var Front1 = PrintVersions[n] + "-front1"; FusionPro.Composition.SetBodyPageUsage(Front1,true); FusionPro.Composition.SetBodyPageUsage("BlankBack", PrintVersions.length % 2); } } Thanks for all your help Lisa Quote Link to comment Share on other sites More sharing options...
mclisa81 Posted July 21, 2011 Author Share Posted July 21, 2011 I forgot to mention something. This not the whole document. I have other pages within the template. Some static, some overflow (pulling in pdfs with unknown page counts). So, I guess the question is, I have the 1 blank page that works, giving me an even number of pages. Now, can the number of pages be counted and then blanks added if needed to be divisible x4. Would seeing the template help you, help me? Thanks again Lisa Quote Link to comment Share on other sites More sharing options...
lisa Posted November 2, 2012 Share Posted November 2, 2012 Hi Lisa, I am trying to something very similar. I have 19 pages all set to unused in my template. The user selection in form filling will determine which pages will print and which will not. I have two headers (graphic) for each page that I want to switch depending on if the current page is odd or even. Seems like your code should work for this. But I’m confused by this line of code “if (Field(i+1) != "") {” What is field? Is that an actual field in your DB? I’d appreciate any help you can give! Thanks, Lisa Quote Link to comment Share on other sites More sharing options...
esmith Posted November 2, 2012 Share Posted November 2, 2012 “if (Field(i+1) != "") {” What is field? Is that an actual field in your DB? mclisa was defining fields based on their column position in the data file rather than by name. "i" is defined in the FOR loop as being numbers 0-66 so "i+1" would result in "1-67". The effect is that the loop cycles through the first 67 columns of data in her data file and adds a value to an array if there is a value in that column for that record. She then uses the array to determine which pages to use for that record. I am trying to something very similar. I have 19 pages all set to unused in my template. The user selection in form filling will determine which pages will print and which will not. I have two headers (graphic) for each page that I want to switch depending on if the current page is odd or even. Seems like your code should work for this. I believe mclisa's rule is applied to the OnRecordStart callback rule. Using her logic to determine whether a page should be enabled or not on your end, you could possibly assign unique names to each graphic header frame on each page and then assign the correct left- or right-hand image (via a FindGraphicFrame() function) based on whether the element in the array of active pages is even or odd. Keep in mind that the array begins with element "0" so element "1" is actually an even page. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.