Jump to content

Page Usage set by number of active variables?


Stack

Recommended Posts

I'm working on a business card template for a client and I'm stumped...

 

BAI_screenshot.jpg

 

In the above screenshot, I need the blue vertical separator to adjust in height according to the number of active variables within the text box (highlighted in red box). So in other words, if the user doesn't include a cell number, the cell variable and "c" prefix would be hidden, the other numbers would shift down (it's bottom aligned) and the separator would reduce in height to then align with the top-most active variable in the box. I first tried inserting a portion of the separator as an inline image but didn't have success; the images wouldn't overlap to make a smooth line, and the spacing between each line kept increasing. So the only way I can think to achieve my goal is to setup multiple pages with the separator at varying heights and use the OnRecordStart callback to set the page usage.

 

So my question is, is there any way to use the total number of active variables in a text box to set the page usage? There are 4 total variables in the box (Office, Extension, Cell and Fax). If only 2 of those variables are active, can I set the template to return page 2, for example? Or can anybody recommend a better method to achieve what I'm trying to do? Thanks in advance!

Link to comment
Share on other sites

You could try using a 2 column table with a blue border set on the right side of the first column:

var numbers = [
 ['o', Field("Office")],
 ['e', Field("Extension")],
 ['f', Field("Fax")],
 ['c', Field("Cell")],
 ['', '1835-A Forest Drive<br>Annapolis, MD 21401']
].filter(function(s){ return s[1] });

var table = new FPTable();
table.AddColumns(0.5 * 7200, 2 * 7200); // Left column is .5", right column is 2"
numbers.forEach(function(num) {
 var row = table.AddRow();
 row.Cells[0].SetBorders('Thick', 'Blue', 'Right');
 var [abbreviation, number] = num;
 if (abbreviation)
   abbreviation = '<color name="Orange">' + abbreviation + '</color>';
 row.SetContents(abbreviation, number);
});
return table.MakeTags();

Link to comment
Share on other sites

Step, thanks for the reply! I was apprehensive at first but I played around with the coding and have it just about setup. The only issue I'm having now is being able to control line height and being able to adjust the width of that border. Setting it to "thick" is too wide but "thin" is too narrow. Is there any way to adjust it (and the line height) numerically?
Link to comment
Share on other sites

The only issue I'm having now is being able to control line height and being able to adjust the width of that border. Setting it to "thick" is too wide but "thin" is too narrow. Is there any way to adjust it (and the line height) numerically?

For the border width, you could try "Medium" instead. The choices, as listed in the FusionPro Tags Reference Guide in the section "About Cell Tag Attributes", and in the FusionPro User Guide in the section "How to use the Table Object", are "none", "thin", "medium", or "thick".

 

For the line height, you can just adjust the cell margins, like so:

  row.Cells[0].Margins = { Top:20, Bottom:20, Left:10, Right:10 };

You'll probably need to play around with the numbers to get what you want. Or, you could just modify the Leading settings in the Paragraph Formatting dialog for the paragraph calling out the table rule.

Link to comment
Share on other sites

Guys, thank you both for the replies. I'm just not having luck duplicating the formatting of the original card and our clients are particular so I don't think this table route will work. So is there a way to set page usage based on the number of active variables in a specific text frame?
Link to comment
Share on other sites

Sure, you can put this in your OnRecordStart callback:

var activeFields = [Field("Office"), Field("Extension"), Field("Fax"), Field("Cell")].filter(String).length;
FusionPro.Composition.SetBodyPageUsage(activeFields, true);

Note: the above code assumes you've named the pages in your template 0–4 and have them set to "Unused."

Link to comment
Share on other sites

Sure, you can put this in your OnRecordStart callback:

var activeFields = [Field("Office"), Field("Extension"), Field("Fax"), Field("Cell")].filter(String).length;
FusionPro.Composition.SetBodyPageUsage(activeFields, true);

Note: the above code assumes you've named the pages in your template 0–4 and have them set to "Unused."

Or you can do this without naming the pages:

var activeFields = [Field("Office"), Field("Extension"), Field("Fax"), Field("Cell")].filter(String).length + 1;
FusionPro.Composition.SetBodyPageUsage(activeFields, true);

Link to comment
Share on other sites

Or you can do this without naming the pages:

var activeFields = [Field("Office"), Field("Extension"), Field("Fax"), Field("Cell")].filter(String).length + 1;
FusionPro.Composition.SetBodyPageUsage(activeFields, true);

 

True – assuming that the first page in your template has 0 active fields, the second page has 1 active field, etc and if the card has a back it is the last page in the template.

Link to comment
Share on other sites

True – assuming that the first page in your template has 0 active fields, the second page has 1 active field, etc and if the card has a back it is the last page in the template.

Or, you could have just one page, and multiple overlapping text frames with those names, and call out the one you want like so:

var activeFields = [Field("Office"), Field("Extension"), Field("Fax"), Field("Cell")].filter(String).length;
for (var i = 0; i <= 4; i++)
 FindTextFrame(i).suppress = (i != activeFields);

Another alternative is to set up a series of Repeatable Component (Template) pages, and call out the appropriate one in a rule. Also, if you are composing via FusionPro VDP Server or Producer, you can modify the size and position of frames. Although still I think the table method could be made to work.

Edited by Dan Korn
Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...