MarcomCentral (PTI) and FusionPro User Communities

MarcomCentral (PTI) and FusionPro User Communities (http://forums.pti.com/index.php)
-   The JavaScript Library (http://forums.pti.com/forumdisplay.php?f=23)
-   -   Location of Email field based on CopyFit (http://forums.pti.com/showthread.php?t=4537)

EricC March 31st, 2016 09:33 AM

Location of Email field based on CopyFit
 
I have a business card with two text boxes: TextBoxLeft and TextBoxRight.

TextBoxLeft contains the following fields/rules:
- Name
- Title 1
- Title 2
- Title 3
- Email Address

TextBoxRight contains the following fields/rules:
- Address Line 1
- Address Line 2
- City, State Zip Code
- Phone Number
- Fax Number
- Website

Regarding TextBoxLeft ... sometimes the titles are so long that the Email Address gets truncated (even with CopyFit).

So I want to write a rule that does this:
- If all of the text in TextBoxLeft does not fit
Move the Email Address field to TextBoxRight
- Otherwise, Email Address remains in TextBoxLeft

Dan Korn March 31st, 2016 02:06 PM

Re: Location of Email field based on CopyFit
 
It's hard to say without seeing the job, but you can probably accomplish what you want by connecting the two text frames into a single flow. Make the first box just big enough to hold the email address if it's one one line, then it will flow to the other box if it doesn't fit. Make sure to turn off hyphenation for the paragraph containing the email address (actually, you probably want it off for every paragraph in this case). You can tweak the results a bit if you replace the hard returns between lines with soft returns (by typing Ctrl-Enter instead of just Enter) and adjusting the Widows setting for the single paragraph.

For a more specific answer, I would need to see the job, or at the very least know what kind of copyfitting you're doing. Are you using full-flow copyfitting, by checking the "Adjust text to fit" box in the Overflow Options dialog? Or are you using per-line copyfitting, by calling CopyfitLine or a similar function?

Dan Korn March 31st, 2016 02:21 PM

Re: Location of Email field based on CopyFit
 
If you're doing full-flow copyfitting, you can do some tricks in the OnCopyfit callback rule. For instance, you can have the text completely move to another frame if it doesn't fit, like so:
Code:

if (FusionPro.Composition.CurrentFlow.name == "TextBoxLeft")
{
  if (!Copyfit(new MagnifyAttributes("text", 25, 400, 6, 72)))
  {
    ReportWarning("Could not copyfit text in flow " +
                  FusionPro.Composition.CurrentFlow.name);
    FusionPro.Composition.CurrentFlow.content = "";
    FindTextFrame("TextBoxRight").content = FusionPro.Composition.CurrentFlow.originalContent;
  }
}

For your specific requirements, there are several things you could do. Without having to mess around with parsing tags and such, I think you can do this: Set up two completely separate sets of two frames each, one with the two frames in the nominal layout (with the email in the left frame), and another with the two frames in the alternate layout (with the email in the right frame). So four frames total, named something like TextBoxLeft, TextBoxRight, TextBoxLeftAlt, and TextBoxRightAlt. Set the two alternate frames to be suppressed in OnRecordStart:
Code:

FindTextFrame("TextBoxLeftAlt").suppress = true;
FindTextFrame("TextBoxRightAlt").suppress = true;

Then in OnCopyfit, if things don't fit, suppress the nominal frames and show the alternate ones:
Code:

if (FusionPro.Composition.CurrentFlow.name == "TextBoxLeft")
{
  if (!Copyfit(new MagnifyAttributes("text", 25, 400, 6, 72)))
  {
    ReportWarning("Could not copyfit text in flow " +
                  FusionPro.Composition.CurrentFlow.name);

    FindTextFrame("TextBoxLeft").suppress = true;
    FindTextFrame("TextBoxRight").suppress = true;
    FindTextFrame("TextBoxLeftAlt").suppress = false;
    FindTextFrame("TextBoxRightAlt").suppress = false;
  }
}


EricC March 31st, 2016 03:03 PM

Re: Location of Email field based on CopyFit
 
Hi Dan,

I like your first idea - moving all of the text from the left frame to the right frame. However in my scenario, I only want to move one FIELD (Email Address) from the left text frame to the right text frame.

So, I tried out your second idea:

1. Create 2 left text boxes and 2 right text boxes

2. OnRecordStart, suppress TextBoxLeftAlt and the TextBoxRightAlt

3. OnCopyfit, if things don't fit in TextBoxLeft, suppress the nominal frames and show the alternate ones

I am pretty sure I did this correctly, but when I preview the template in Acrobat, I see the content in all 4 frames.

The TextBoxLeft text box has the solid red line at the bottom (the visual indicator that the text is not fitting), so I would have expected the two nominal boxes to be suppressed. But they're not.

Any ideas?

Dan Korn March 31st, 2016 03:20 PM

Re: Location of Email field based on CopyFit
 
Quote:

Originally Posted by EricC (Post 18465)
I am pretty sure I did this correctly, but when I preview the template in Acrobat, I see the content in all 4 frames.

The TextBoxLeft text box has the solid red line at the bottom (the visual indicator that the text is not fitting), so I would have expected the two nominal boxes to be suppressed. But they're not.

Any ideas?

Run a regular composition instead of a preview and see what warning or error messages it has.

You may need to modify the OnCopyfit rule to this:
Code:

if (FusionPro.Composition.CurrentFlow.name == "TextBoxLeft")
{
  if (!Copyfit(new MagnifyAttributes("text", 25, 400, 6, 72)))
  {
    ReportWarning("Could not copyfit text in flow " +
                  FusionPro.Composition.CurrentFlow.name);

    FusionPro.Composition.CurrentFlow.content = "";
    FindTextFrame("TextBoxRight").suppress = true;
    FindTextFrame("TextBoxLeftAlt").suppress = false;
    FindTextFrame("TextBoxRightAlt").suppress = false;
  }
}

This works for me in a test job. I can post it here if you want.

EricC March 31st, 2016 03:29 PM

Re: Location of Email field based on CopyFit
 
Hi Dan,
Thanks for the quick reply.

The error log says:

Code:

Job started 17:02:06 - 1459458126.
Creator: FusionPro(TM) VDP Designer 9.3.21

Composing record #1, input record 6
OnCopyfit, line 6: warning: Could not copyfit text in flow TextBoxLeft
The amount of text inserted into a flow exceeds the depth
of all frames in the flow <TextBoxLeft>.  Text is truncated.
Text does not fit in the last frame on page 1 at (0.22, 0.72).
Job ended 17:02:07 - 1459458127.
Total Job Time: 1s

Using your modified code, it made the content of TextBoxLeft disappear, but the content of TextBoxRight also needs to disappear.

Dan Korn March 31st, 2016 03:59 PM

Re: Location of Email field based on CopyFit
 
1 Attachment(s)
Quote:

Originally Posted by EricC (Post 18468)
Using your modified code, it made the content of TextBoxLeft disappear, but the content of TextBoxRight also needs to disappear.

Hmm, I'm not sure why that's not working for you. It might have to do with the order in which the frames are processed.

You could try to just set the contents of the right frame to nothing instead of suppressing it:
Code:

FindTextFrame("TextBoxRight").content = "";
The other thing you can do, if the "alt" frames are showing and suppressing properly, and if your template has a white background, is set those "alt" frame to fill with White. Then they'll just cover up the other frames.

There are other possible solutions as well.

Anyway, I've attached a sample job which seems to do what you want. Place it in the Cellphone Tutorial folder and compare the preview of records 1 and 2.

EricC March 31st, 2016 04:10 PM

Re: Location of Email field based on CopyFit
 
I tried
Code:

FindTextFrame("TextBoxRight").content = "";
and it still shows the contents of TextBoxRight.

I can't figure it out and I've been at it off and on all day today. I'll try again some more tomorrow. Thanks for your help Dan.

EricC April 1st, 2016 02:52 PM

Re: Location of Email field based on CopyFit
 
Dan,
I deleted all of the text boxes, recreated them and now the rule is working. Thanks a ton for your help!


All times are GMT -7. The time now is 06:47 PM.

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