PDA

View Full Version : How do I get the name of the current frame?


juliazo
October 23rd, 2012, 10:04 AM
Hi all,

I'm trying to find out if it's possible to get the name of the current text frame (for example "01") so I can then use it in the rule.

In other words, it'd be great if the FindTextFrame() function could be used to find the name of the current text frame, as opposed to the name of the specific text frame that one passes in the function.

Here's the scenario:

I have 18 pages with 8 text frames on each, and I'd like to be able to use only one rule that uses the frame names as variables to modify the specifics of the rule, as opposed to having to write one distinct rule for each of the 144 text frames.

Hope this is clear, let me know if not and I can provide more info.

Thanks!

Julian

Dan Korn
October 23rd, 2012, 10:39 AM
In FusionPro 8, you can check the "Re-evaluate this rule for every text flow" box on the Rule Editor dialog, and then you can use the FusionPro.Composition.CurrentFlow.name property, like so:
var currentFrame = FindTextFrame(FusionPro.Composition.CurrentFlow.na me);Or, in your case, you probably want to do something like this:
switch (FusionPro.Composition.CurrentFlow.name)
{
case "A":
// something specific to frame "A"
break;
case "B":
// something specific to frame "B"
break;
// etc. ...
}If you're in an earlier version of FusionPro (6 or 7), then you can't have a standard rule work differently for different frames, so the above won't work. However, you can still use the FindTextFrame function in a loop in the OnRecordStart callback rule to "inject" different contents into each frame. The OnRecordStart logic might look something like this (depending on your frame naming convention):
for (var page = 1; page <= 18; page++)
{
for (var frameNum = 1; frameNum <= 8; frameNum++)
{
var curFrameName = "P" + page + "-" + frameNum;
var currentFrame = FindTextFrame(curFrameName);
currentFrame.content = "The content for frame " + curFrameName;
}
}Actually, you might find that last strategy works best for you, even in FusionPro 8.

juliazo
October 23rd, 2012, 11:10 AM
Thank you, Dan!!

You absolutely nailed it, the FusionPro.Composition.CurrentFlow.name is what I was looking for. Thanks again!

juliazo
October 31st, 2012, 04:04 PM
In FusionPro 8, you can check the "Re-evaluate this rule for every text flow" box on the Rule Editor dialog, and then you can use the FusionPro.Composition.CurrentFlow.name property, like so:
var currentFrame = FindTextFrame(FusionPro.Composition.CurrentFlow.na me);Or, in your case, you probably want to do something like this:
switch (FusionPro.Composition.CurrentFlow.name)
{
case "A":
// something specific to frame "A"
break;
case "B":
// something specific to frame "B"
break;
// etc. ...
}If you're in an earlier version of FusionPro (6 or 7), then you can't have a standard rule work differently for different frames, so the above won't work. However, you can still use the FindTextFrame function in a loop in the OnRecordStart callback rule to "inject" different contents into each frame. The OnRecordStart logic might look something like this (depending on your frame naming convention):
for (var page = 1; page <= 18; page++)
{
for (var frameNum = 1; frameNum <= 8; frameNum++)
{
var curFrameName = "P" + page + "-" + frameNum;
var currentFrame = FindTextFrame(curFrameName);
currentFrame.content = "The content for frame " + curFrameName;
}
}Actually, you might find that last strategy works best for you, even in FusionPro 8.
Hello,

Dan, thanks again for your help. Since FusionPro.Composition.CurrentFlow.name only works during composition, and I'd like to be able to test for my rules when building the template, I decided to give it a try with the OnRecordStart rule that you suggested, and it worked great to push the content as I needed!

However, I'm running into a small issue with text formatting (not sure if this is the right forum/thread to be asking this, so please let me know if that's the case):

When pushing content to the frame, I'm appending tags also to format the text (which I get by creating a Formatted Text resource, formatting text the way I need it, then viewing its source). The tags are able to specify a font and a color and a size for the text without issues, but my text shows up in the "left" quadrant, even when the tags specify "center" (the tag is quad="C").

Do you know if this is expected behavior when pushing content to a text frame, or if I should submit a support ticket?

Thanks!

Julian

Adobe Acrobat Pro v9.5.2
FusionPro VDP Creator 8.2.5
Mac OS X 10.8.2

esmith
November 1st, 2012, 11:09 AM
quad="c" is a property of the <p> tag rather than a standalone tag. Can't tell from your post is that is how you are using it?
<p quad="c">

juliazo
November 1st, 2012, 11:30 AM
Thanks for the reply, Eric!

I was in the process of looking up the contents of the variable I'm using to add the formatting tags so that I could post them on the thread...and it was then that I realized that I had a typo in the variable name. I feel kinda dumb now, but at least the problem is no more, so thank you for helping me discover it! :)

Julian

juliazo
November 1st, 2012, 11:56 AM
Just for kicks, here's the logic I'm using (hopefully this can help someone down the line)

Rule added to OnRecordStart:

for (var frameNum = 1; frameNum <= Field("TagCount"); frameNum++)
{
var curFrameName = "N_" + frameNum;
var currentFrame = FindTextFrame(curFrameName);
currentFrame.content = foodName2 + softReturn(Field("FoodName_" + frameNum));
}

"TagCount" and "FoodName_##" are user-driven variables.

"foodName2" is a JavaScript Global variable containing the formatting tags:

var foodName2 = '<p style="(no style)" br="false" override="true" quad="C" leading="260" findent="0" lindent="0" rindent="0" leadbefore="0" leadafter="0" widows="1" kerning="true" hyphenate="false" skipifempty="true" skipifemptyvar="false" noparabreakoncopyfit="false"><tracking newsize="0"><f name="Helvetica Neue Light"><z newsize="22.0"><color name="202-15/100/70/25">'


This rule effectively pushes the content to the text frames, which are named "N_1" through "N_48".