Jump to content

Suppress a text frame based on copyfit


Recommended Posts

Checking if it there is a way (that I am not aware of) to suppress a text frame, if the content in the frame reaches the copyfit threshold.

 

I have not been able to accomplish this, I presume because the frame suppression needs to be applied via OnRecordStart, which is called before OnCopyfit?

 

Is there any way around this?

 

 

 

Thanks.

Link to comment
Share on other sites

Sure, just modify your OnCopyfit rule like so (add the lines in red):

if (!Copyfit(new MagnifyAttributes("text", 25, 400, 6, 72)))
[color=Red]{[/color]
   ReportWarning("Could not copyfit text in flow " + 
                 FusionPro.Composition.CurrentFlow.name);
[color=Red]    FusionPro.Composition.CurrentFlow.content = "";
}[/color]

Link to comment
Share on other sites

Actually, I am tying to suppress the frame itself, so it can have a white background. This is to display a warning message to a user who enters too much information on a business card.

Oh, in that case, just change the added line to output the warning, something like this:

if (!Copyfit(new MagnifyAttributes("text", 25, 400, 6, 72)))
{
   ReportWarning("Could not copyfit text in flow " + 
                 FusionPro.Composition.CurrentFlow.name);
   FusionPro.Composition.CurrentFlow.content =
       "<para><color name=Red>CONTENT DOES NOT FIT</para>";
}

Link to comment
Share on other sites

How would you do this if copyfit was NOT turned on?

We have a template that allows clients to choose fonts & font sizes & copyfit is off.

If their text doesn't fit it might be nice to send them a message rather than relying on them to notice.

 

Thanks

Mike G.

Link to comment
Share on other sites

How would you do this if copyfit was NOT turned on?

We have a template that allows clients to choose fonts & font sizes & copyfit is off.

If their text doesn't fit it might be nice to send them a message rather than relying on them to notice.

 

Thanks

Mike G.

Well, the OnCopyfit rule isn't invoked if Copyfit is not enabled, so you need to have it turned on. However, if you want to invoke the rule without actually copyfitting the text, then you can set the minimum and maximum magnification in the MagnifyAttributes object to both be 100 percent, by changing the first line to this:

if (!Copyfit(new MagnifyAttributes("text", 100, 100, 4, 200)))

If you need to actually do copyfitting in other frames, you can switch off of FusionPro.Composition.CurrentFlow.name.

 

(Note that you don't actually need to call the Copyfit function in the OnCopyfit rule; you can do other things based on the flow/frame name. However, in FusionPro 8, it's easier to do flow-specific things in a regular rule by checking the "Re-evaluate this rule for every text flow" box.)

Edited by Dan Korn
Link to comment
Share on other sites

I think I was trying to get too fancy with it. I was thinking of having a warning message frame with a white background, but also showing the user the overflowing text underneath, as a cue for where they need to reduce the content.

 

The solution you provided is simpler, and works just fine. Thanks Dan.

Link to comment
Share on other sites

  • 2 weeks later...

Ok I see how to get the error in the message file & in the text box.

Now If the client's text is not copy fitted:

e.g. if (!Copyfit(new MagnifyAttributes("text", 100, 100, 6, 72)))

Is there a way to enlarge the error message in the text box?

I've tried the CopyfitLine but both the staticpart, dynpart, are comming out at the same size.

Thanks

Link to comment
Share on other sites

Ok I see how to get the error in the message file & in the text box.

Now If the client's text is not copy fitted:

e.g. if (!Copyfit(new MagnifyAttributes("text", 100, 100, 6, 72)))

Is there a way to enlarge the error message in the text box?

I've tried the CopyfitLine but both the staticpart, dynpart, are comming out at the same size.

Thanks

I'm not sure why you're trying to mix single-line copyfitting (CopyfitLine) in with full-flow copyfitting (Copyfit/OnCopyfit). That's almost never what you want to do.

 

I think what you do want to do in this case is to call the Copyfit function again after setting the error message into the frame, like so:

// Don't actually copyfit; we only want to detect the text
// not fitting and show a warning message in the frame.
if (!Copyfit(new MagnifyAttributes("text", 100, 100, 4, 200)))
{
   ReportWarning("Could not fit text in flow " + 
                 FusionPro.Composition.CurrentFlow.name);

   FusionPro.Composition.CurrentFlow.content =
       "<para><color name=Red>CONTENT DOES NOT FIT</para>";

   // Now copyfit the warning text, expanding to fill.
   FusionPro.Composition.CurrentFlow.expandToFill = true;
   if (!Copyfit(new MagnifyAttributes("text",  25, 400, 6, 72)))
   {
       ReportWarning("Could not copyfit warning in flow " + 
                     FusionPro.Composition.CurrentFlow.name);
   }
}

Link to comment
Share on other sites

  • 2 months later...

I was going over copy fit again. I thought it would be nice to give clients a warning & still let them see the text they've entered. So I'd use a watermark with info (got that to work). Then; to direct them to the specific box; I'd have it change color (I haven't got that to work). Here's the code:

 

if (!Copyfit(new MagnifyAttributes("text", 100, 100, 4, 200))) {

FindGraphicFrame("TextOverflowWarning").SetGraphic("TextOverflowWarning.pdf");

var warningColor = FindTextFrame(FusionPro.Composition.CurrentFlow.name);

FindTextFrame("warningColor").fillColorName = "Red";

ReportWarning("Could not fit text in flow " + FusionPro.Composition.CurrentFlow.name);

}

 

This way clients can see how much "fixing" is necessary. I don't know if this is even possible. Please let me know.

Thanks

Mike G.

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