Jump to content

Graphic Scaling Question


ReminderVDP

Recommended Posts

Is there any way to scale a graphic in a graphic frame and tell it to not scale larger than 100%? We have several logos that need to be used in several locations in one layout at different sizes but we don't want the largest logo to be larger than 100%. Is there a tag or a rule that can make this happen?
Link to comment
Share on other sites

Not directly. However, you can measure the graphic, compare its dimensions to the frame's, and then change the scaling or clipping (or place the graphic in another frame) accordingly. The measurement is similar to the logic in this post:

http://forums.pti.com/showpost.php?p=1367&postcount=2

 

So you could do something like this in OnRecordStart:

var graphic = Rule("PI_Rule"); // rule that returns a graphic resource
var frame = FindGraphicFrame("YourFrameName"); // name of the frame

// Measure the graphic.
var TM = new FusionProTextMeasure;
TM.useTags = true;
var err = TM.CalculateTextExtent(graphic.content);
if (err)
   throw "Error measuring graphic resource: " + res + ": " + TM.messages;

// If the graphic is bigger than the frame, scale it down.
if (TM.textWidth > frame.width || TM.textHeight > frame.height)
   frame.scale = "Best Fit";

Link to comment
Share on other sites

  • 4 months later...

If I leave the rule as is with updating my rule name and frame name I get ReferenceError: res is not defined.

 

If I take that part of the rule out, I get a Unknown graphic scaling attribute value Best Fit

Edited by dreimer
Link to comment
Share on other sites

If I leave the rule as is with updating my rule name and frame name I get ReferenceError: res is not defined.

 

If I take that part of the rule out, I get a Unknown graphic scaling attribute value Best Fit

Sorry, I must have typed that rule up off the cuff, without trying it out. The "throw" line has the wrong variable name in it.

 

Also, in the very last line, if you're using FusionPro 8.0 or later, you can specify "Best Fit", as shown in the Graphic Frame Properties dialog, or you can specify "Best". In older versions, you have to specify "Best".

 

Try this:

var graphic = Rule("YourGraphicRule"); // rule that returns a graphic resource
var frame = FindGraphicFrame("YourFrameName"); // name of the frame

// Measure the graphic.
var TM = new FusionProTextMeasure;
TM.useTags = true;
var err = TM.CalculateTextExtent(graphic.content);
if (err)
   throw "Error measuring graphic resource: " + graphic + ": " + TM.messages;

// If the graphic is bigger than the frame, scale it down.
if (TM.textWidth > frame.width || TM.textHeight > frame.height)
   frame.scale = "Best";

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