Go Back   MarcomCentral (PTI) and FusionPro User Communities > Software-Related Talk > The JavaScript Library > Graphic Rules


Thread Tools Search this Thread Display Modes
Old December 15th, 2017, 04:01 PM
Ryan_B Ryan_B is offline
Regular Contributor
Join Date: Mar 2015
Location: Kansas City, MO
Posts: 70
Default Move a text frame based on the size of a graphic

I was wondering if there is a way to dynamically set the x coordinates of a text frame based on the dimensions of an uploaded graphic.

I have a graphic frame that the user uploads a logo to. To the left of said frame I have a text frame that holds the company's slogan. I'm looking for a way to move the text frame so that it always butt's up against the left of the uploaded logo.

My original thought was to use FusionProTextMeasure to get the width of the uploaded graphic, using:
var graphic = Field("Logo");

function getGraphicWidth(input){
    var tm = new FusionProTextMeasure;
    tm.useTags = true;
    return tm.textWidth;
return getGraphicWidth(graphic);
Using that returned value and doing some calculations, I would be able to set my x coordinates for my text frame in order for it to butt up against the graphic frame. The problem I'm realizing is that the returned value is the width of the graphic before getting resized to fit in the graphic frame. So hypothetically, if the uploaded image was larger than the graphic frame, or the template itself, the returned value for the width would obviously not be accurate, thus making my text frame not butt up against the logo.

In closing, is there a way to get the width of an uploaded image after it's been inserted into a graphic frame? Or, if anyone knows of a simpler/better/more accurate way of doing this, I'm all ears. TIA.
Ryan Boever
FusionPro VDP Designer 9.3.36
Adobe Acrobat XI 11.0.07
Windows 10
Reply With Quote
Old December 15th, 2017, 05:56 PM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
Join Date: Aug 2008
Location: Chicago, IL
Posts: 4,694
Default Re: Move a text frame based on the size of a graphic

You're really asking two questions:
  1. Can the position of a frame be modified?
  2. Can the final result of scaling a graphic to a graphic frame be determined?
The answer to both is Yes, with some qualifications.

Frames can be moved and resized like so:
FindTextFrame("YourFrameName").x = 7200; // <- value in hundredths of points
But you need to compose with Producer or Server. If you are composing only locally in Creator/Desktop, then you can't move a frame, but you can do things like adjust the left indent, or use a table, or some other tricks, to position text.

As for finding the final scaling applied to a graphic, FusionPro won't tell you that exactly, but you can figure it out. Depending on what scaling factor you have applied to the graphic frame, you can do some math to basically duplicate what FusionPro is doing to the graphic, based on the initial width and height of the graphic itself, which you already know how to get using FusionProTextMeasure, and the dimensions of the frame, which you can get by calling FindGraphicFrame and accessing properties such as width and height from the returned object. (You can also interrogate the scaling and positioning set for the graphic frame. Note that you do NOT need a Producer or Server license to get this frame information, only to modify a frame's position or size.)

However, depending on how the job is set up, you might just want to use an inline graphic, with a hard-coded height in the <graphic> tag, which will automatically scale the graphic proportionally and line the text up with it.

I might be able to offer more specific suggestions if I could see what you're trying to do, even just a picture of the desired output for a couple different variations.
Dan Korn
FusionPro Developer / JavaScript Guru / Forum Moderator
PTI Marketing Technologies | Printable | MarcomCentral

I am a not a Support engineer, and this forum is not a substitute for Support. My participation on this forum is primarily as a fellow user (and a forum moderator). I am happy to provide help and answers to questions when I can; however, there is no guarantee that I, or anyone else on this forum, will be able to answer all questions or fix any problems. If I ask for files to clarify an issue, I might not be able to look at them personally. I am not able to answer private messages, emails, or phone calls unless they go through proper Support channels. Please direct any sales or pricing questions to your salesperson or inquiries@marcom.com.

Complex template-building questions, as well as all installation and font questions or problems, should be directed to FusionProSupport@marcom.com. Paid consulting work may be required to fulfill your template-building needs.

This is a publicly viewable forum. Please DO NOT post fonts, or other proprietary content, to this forum. Also, please DO NOT post any "live" data with real names, addresses, or any other personal, private, or confidential data.

Please include the specific versions of FusionPro, Acrobat, and your operating system in any problem reports or help requests. I recommend putting this information in your forum signature. Please also check your composition log (.msg) file for relevant error or warning messages.

Please post questions specific to the MarcomCentral Enterprise and Web-to-Print applications in the MarcomCentral forum. Click here to request access. Or contact your Business Relationship Manager (BRM/CPM) for assistance.

Please direct any questions specific to EFI's Digital StoreFront (DSF) to EFI support.

How To Ask Questions The Smart Way

The correct spellings are JavaScript, FusionPro, and MarcomCentral (each with two capital letters and no spaces). Acceptable abbreviations are JS, FP, and MC (or MCC). There is no "S" at the end of "Expression" or "Printable"! The name of the product is FusionPro, not "Fusion". "Java" is not is not the same as JavaScript.

Check out the JavaScript Guide and JavaScript Reference! FusionPro 8.0 and newer use JavaScript 1.7. Older versions use JavaScript 1.5.

return "KbwbTdsjqu!spdlt\"".replace(/./g,function(w){return String.fromCharCode(w.charCodeAt()-1)});
Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT -7. The time now is 06:01 AM.

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