Jump to content

Moving frames in Javascript


Recommended Posts

Moving frames in Javascript

In FusionPro Producer (formerly FP Direct or FP Server), the ability to move a frame’s position and size can be controlled in JavaScript using the OnRecordStart callback rule.

 

Can I get a pointer to where I find the documentation for this? It appears that the language reference guide that installs with FP8 hasn't been updated to include this (and still says Copyright 2011). FindTextFrame("name").x = val; is apparently not the way to do it.

Link to comment
Share on other sites

Can I get a pointer to where I find the documentation for this? It appears that the language reference guide that installs with FP8 hasn't been updated to include this (and still says Copyright 2011). FindTextFrame("name").x = val; is apparently not the way to do it.

That is indeed the way to do it. Although you need to have a FusionPro 8 VDP Producer (Direct or Server) license. If you have a 7.2 or earlier license, or a VDP Creator (Desktop) license, it won't work, although you can upload your job to a FusionPro 8 VDP Producer system such as MarcomCentral and compose it there to move frames.

 

As for the documentation, the copyright date for FusionPro 8 may still say 2011, but it's the right doc. (Look for a section about arbitrarily adjusting stacking.) I'll look into the documentation for the frame API specifically and figure out what happened to that.

 

Note that the Building Blocks dialog fully documents the frame API, on the Objects tab under "Frames."

Link to comment
Share on other sites

In the v8.0 User Guide, there is a paragraph addressing this new functionality at the bottom of p.232. It states,

You can resize and move text and graphic frames by changing their properties in JavaScript in OnRecordStart. Note, however, that this will only work for the FusionPro Producer (formerly known as FP Direct and FP Server products.) If used with the Designer or Creator (aka Desktop) tool, then the moved/resized frames will be highlighted in the output, and an error message is generated to indicate that the Producer software is required to create final output of moved frames.

To use this new functionality you would use the OnRecordStart callback rule. Here is an example of code that could be used within it:
var frame = FindTextFrame("TextFrame1"); //set this value to the name of the frame
var NewHeight = 36000; //5 inches specified in hundreths of a point
var NewWidth = 21600; //3 inches specified in hundreths of a point
var NewX = 21600; //3 inches specified in hundreths of a point
var NewY = 28800; //4 inches specified in hundreths of a point

frame.height = NewHeight;
frame.width = NewWidth;
frame.x = NewX;
frame.y = NewY;

I have also attached a sample job that uses this code.

Move Frame.zip

Link to comment
Share on other sites

I'm using Desktop but it will be composed on MarcomCentral. I guess I was under the impression that the frame itself would move in the preview. I see now that the contents do move but the frame doesn't, I just had to make the frame bigger to see it.

I'm not sure what you mean by, "the contents do move but the frame doesn't." The entire frame should move in Preview, although if you don't have a Producer license, the frame will have a random border and fill applied. It might help if you could post a sample job or a screenshot of what you're seeing. We do want to know about any issues with this new functionality.

Edited by Dan Korn
Link to comment
Share on other sites

Please see attached. It's not a big deal, I just didn't notice it at first so I didn't think I got the JavaScript right. I do see that 6 point border being an issue though as positioning of the text will be off when that's gone.

I see. The frames may not appear in Preview if they don't overlap other frames, as the Preview system is based on the locations of the original frames, and doesn't know that they've been moved. You pretty much need to do a regular (non-Preview) composition to see frames which have been moved significantly in JavaScript. The other option is to place an empty frame over the entire page, which will force the entire page to be redrawn in Preview.

Edited by Dan Korn
Link to comment
Share on other sites

  • 6 months later...

So I got my text frames to move correctly thanks to this thread, but now I need to know how to move them based on a variable in a field, but to leave them "as is" otherwise.

 

Here's my statement now that isn't working. I need to center 3 frames when a currency field has zero cents:

if ((Right("Price-2for"),2) == "00");
return
{
FindTextFrame("K (Price n for)").x = 8776
FindTextFrame("K (Price n for)").y = 6235
FindTextFrame("J (Qty n for)").x = 3996
FindTextFrame("J (Qty n for)").y = 4053
FindTextFrame("J (For only)").x = 8374
FindTextFrame("J (For only)").x = 4025
}

Link to comment
Share on other sites

It's hard to tell without seeing exactly what you are doing but this JavaScript might be a little closer to what you intended:

 

if (Right(Field("Price-2for"),2) == "00")
{
FindTextFrame("K (Price n for)").x = 8776;
FindTextFrame("K (Price n for)").y = 6235;
FindTextFrame("J (Qty n for)").x = 3996;
FindTextFrame("J (Qty n for)").y = 4053;
FindTextFrame("J (For only)").x = 8374;
FindTextFrame("J (For only)").x = 4025;
}

Link to comment
Share on other sites

I'm guessing that this change needs to be made so that there isn't conflicting information for the x position of the "J (For only)" text box:

if ((Right("Price-2for"),2) == "00");
return
{
FindTextFrame("K (Price n for)").x = 8776
FindTextFrame("K (Price n for)").y = 6235
FindTextFrame("J (Qty n for)").x = 3996
FindTextFrame("J (Qty n for)").y = 4053
FindTextFrame("J (For only)").x = 8374
[color="Red"]FindTextFrame("J (For only)").y = 4025[/color]
}

Link to comment
Share on other sites

  • 2 months later...

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