Jump to content

Location of Email field based on CopyFit


EricC

Recommended Posts

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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:

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:

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:

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;
 }
}

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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:

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.

Link to comment
Share on other sites

Hi Dan,

Thanks for the quick reply.

 

The error log says:

 

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.

Link to comment
Share on other sites

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:

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.

cellphone-EricC-copyfit.pdf

Link to comment
Share on other sites

I tried

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.

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...