Go Back   MarcomCentral (PTI) and FusionPro User Communities > Support > Issues, Questions, Etc.

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old January 28th, 2016, 04:40 PM
Landisa's Avatar
Landisa Landisa is offline
Junior Community Member
 
Join Date: Jun 2014
Location: United States
Posts: 31
Question Page Number & Rules [SOLVED]

================
UPDATE: 1/29/2016 Listing as solved and leaving code for future people if they need help.
================

I am working on creating several rules based on the page number of a document.

First rule is a barcode for our inserter.
We need to include:

  • customer id
  • current page (2-digit)
  • total pages in record (2-digit)
  • check digit
So it should look something like: CN61341010300
I am having difficulty calling the page numbers in the empty rules though.

Second rule is making it so that the barcode only displays on odd number pages and the first page is a different setup than all the other pages.

Page 1 has a special check digit that signifies start of a document.
Page 2-N have a different check digit to signify that it continues to pull.

How would I call up page numbers in these situations?

Will they work in empty rules or do I need a callback?
__________________
Audra Landis
Computer Systems Admin

VDP Producer v10.0.3
Windows 7 / Windows 10
Acrobat Pro DC (2015.010.20056)

Last edited by Landisa; January 29th, 2016 at 10:06 AM.. Reason: Solved
Reply With Quote
  #2  
Old January 28th, 2016, 06:16 PM
step's Avatar
step step is offline
Senior Contributor
 
Join Date: Jan 2010
Location: Charlotte, NC
Posts: 955
Default Re: Page Number & Rules

Quote:
Originally Posted by Landisa View Post
First rule is a barcode for our inserter.
We need to include:
  • customer id
  • current page (2-digit)
  • total pages in record (2-digit)
  • check digit
Okay, it sounds like you're going to want to make a text rule to return those values and then apply it to the frames in which you'd like for the barcode to display. Is that right?

So the "total pages" are the "total pages of a particular record," is the "current page" the "current page of a particular record" or the "current page of the output file?" There are methods to handle both but for the sake of example, I'm going to assume you're just talking about the current page in the record.
Quote:
Originally Posted by Landisa View Post
I am having difficulty calling the page numbers in the empty rules though.
I don't understand what you mean by that. Can you elaborate on what you mean by "calling page numbers in the empty rules?" Are you referring to rules that return a null value or empty string? If so, why are you worried about calling the page number?

Quote:
Originally Posted by Landisa View Post
Second rule is making it so that the barcode only displays on odd number pages
Easy enough. You can just return an empty string in your text rule when the current page mod 2 is 0. Or just don't put a text frame with that rule in it on even pages.

Quote:
Originally Posted by Landisa View Post
and the first page is a different setup than all the other pages.

Page 1 has a special check digit that signifies start of a document.
Page 2-N have a different check digit to signify that it continues to pull.
Page 1 has a special check digit that signifies the start of a document like... a 1? I'm not sure what your intent with this "check digit" is. It seems like that information is already included in the barcode but I'll just assume that you want the last two digits to be "01" if it's the first page in the document and "00" if it's any other page in the document. I also just assumed you wanted to make a 3 of 9 barcode but you should be able to easily swap that out with whatever format you prefer:

Code:
var id = 'CN61341'; // Your Client ID field would go here
var pg = FusionPro.Composition.currentPageNumber;
var pgs = FusionPro.Composition.totalPages;
var check = pg == 1 ? 1 : 0;

// Format pg, pgs, & check to 2 digits and join the string.
var digits = [pg,pgs,check].map(function(s){ return Str(FormatNumber('00',s));}).join('');

// If the current page is odd, return the barcode
return pg%2 ? Make39Barcode(id + digits) : '';
That would go in a text rule that is set to "re-evaluate for every text flow" and "treat strings at tagged text" and then you just insert it into your text frames.
__________________
Ste Pennell
FusionPro VDP Creator 9.3.15
Adobe Acrobat X 10.1.1
Mac OS X 10.12

LinkedIn
Reply With Quote
  #3  
Old January 29th, 2016, 09:35 AM
Landisa's Avatar
Landisa Landisa is offline
Junior Community Member
 
Join Date: Jun 2014
Location: United States
Posts: 31
Default Re: Page Number & Rules

Step your code helped me figure out my mistake!
Looks like I just needed to set my code to re-evaluate for every text flow so that it would actually call the page number rather than always using page 1 as the result.

Could this theory be applied to a set of OMR marks (essentially a table with borders that change from 3-fin marks on page 1 and 2-fin marks on pages 2-N)?

I am using this code to apply the marks:
Code:
 //Create 3-Fin OMR Mark using tables and borders
new FPTable;
var OMR = new FPTable;
OMR.AddColumns(7200);
OMR.AddRows(3);
 OMR.Rows[0].minHeight = 1800; //specified in hundredths of a point
OMR.Rows[0].Cells[0].SetBorders("Medium", "Black", "Top");
OMR.Rows[0].Cells[0].Content = "";
 OMR.Rows[1].minHeight = 1800; //specified in hundredths of a point
OMR.Rows[1].Cells[0].SetBorders("Medium", "Black", "Top");
OMR.Rows[1].Cells[0].Content = "";
 OMR.Rows[2].minHeight = 1800; //specified in hundredths of a point
OMR.Rows[2].Cells[0].SetBorders("Medium", "Black", "Top");
OMR.Rows[2].Cells[0].Content = "";
 return OMR.MakeTags();
__________________
Audra Landis
Computer Systems Admin

VDP Producer v10.0.3
Windows 7 / Windows 10
Acrobat Pro DC (2015.010.20056)

Last edited by Landisa; January 29th, 2016 at 09:43 AM..
Reply With Quote
  #4  
Old January 29th, 2016, 10:04 AM
Landisa's Avatar
Landisa Landisa is offline
Junior Community Member
 
Join Date: Jun 2014
Location: United States
Posts: 31
Default Re: Page Number & Rules

Nevermind! I just needed to think it through a little bit. Made each table unique and set an easy if else statement.

I got these to work with the following code:

Code:
 // If the current page is odd, return the barcode
if (pg == 1){
    return pg %2 ? OMR3.MakeTags() : '';
}
else {
    return pg %2 ? OMR2.MakeTags() : '';
}
__________________
Audra Landis
Computer Systems Admin

VDP Producer v10.0.3
Windows 7 / Windows 10
Acrobat Pro DC (2015.010.20056)
Reply With Quote
  #5  
Old January 29th, 2016, 10:36 AM
step's Avatar
step step is offline
Senior Contributor
 
Join Date: Jan 2010
Location: Charlotte, NC
Posts: 955
Default Re: Page Number & Rules

Quote:
Originally Posted by Landisa View Post
Could this theory be applied to a set of OMR marks (essentially a table with borders that change from 3-fin marks on page 1 and 2-fin marks on pages 2-N)?
Sure, you could determine the number of marks (rows) to add based on what page the record is on:
Code:
var pg = FusionPro.Composition.currentPageNumber;
var rows = !--pg+2;

var OMR = new FPTable();
OMR.AddColumns(7200);
for (var i=0; i<rows; i++) {
    var row = OMR.AddRow();
    row.minHeight = 1800; //specified in hundredths of a point
    row.Cells[0].SetBorders('Medium', 'Black', 'Top');
}
return pg%2 ? OMR.MakeTags() : '';
__________________
Ste Pennell
FusionPro VDP Creator 9.3.15
Adobe Acrobat X 10.1.1
Mac OS X 10.12

LinkedIn
Reply With Quote
  #6  
Old January 29th, 2016, 10:40 AM
Landisa's Avatar
Landisa Landisa is offline
Junior Community Member
 
Join Date: Jun 2014
Location: United States
Posts: 31
Default Re: Page Number & Rules

Quote:
Originally Posted by step View Post
Sure, you could determine the number of marks (rows) to add based on what page the record is on:
Nice! I really need to start wrapping my brain around the slimmer code style. My code always feels so barbaric compared to yours XD
__________________
Audra Landis
Computer Systems Admin

VDP Producer v10.0.3
Windows 7 / Windows 10
Acrobat Pro DC (2015.010.20056)
Reply With Quote
  #7  
Old January 29th, 2016, 10:51 AM
step's Avatar
step step is offline
Senior Contributor
 
Join Date: Jan 2010
Location: Charlotte, NC
Posts: 955
Default Re: Page Number & Rules

By the way, just as a little explanation about the 'rows' variable since I know it looks kind of weird:
Code:
--pg
subtracts 1 from the page number.
Code:
!--pg
Converts the number to a boolean (true/false). In this case we're testing that the page number minus one is zero; if it is, the boolean returns true and if it's greater than 0 it returns false.
Code:
!--pg+2
The binary value of the boolean (1: true, 0: false) is converted to an integer by performing arithmetic on it. In this case we're adding 2 so that the number of rows will be 2 when the page is greater than one (0 + 2 = 2) and 3 when then page number is 1 (1 + 2 = 3).

It by no means has to be written that way. I was just saving a few keystrokes but it could certainly be written in a more easy-to-read format:

Code:
var rows = pg==1 ? 3 : 2;
__________________
Ste Pennell
FusionPro VDP Creator 9.3.15
Adobe Acrobat X 10.1.1
Mac OS X 10.12

LinkedIn
Reply With Quote
Reply

Tags
barcode, number, numbering, odd, page

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 01:58 AM.


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