Expand my Community achievements bar.

SOLVED

xfa.layout.y in flowed layout

Avatar

Level 4

Hi,

I used this line in version 7 of the designer in the layoutReady-event:

xfa.host.messageBox(xfa.layout.y(this, "in"));

// this being a subform in a flowed layout

Now with the current version I keep getting an error about differing arguments.

[I have serveral blocks of text seperated by lines (wrapped with subforms). In the page footer there is another line. Now the customer wants to omit automatically the last line when it comes too close to the footer line.]

Hope someone has already discovered a trick.

Uli

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi Uli,

I think the problem is using the messageBox to show the y-coordinate. Instead if you use the JavaScript Console with the following script. Press Control+J to open the console:

console.println("y-coordinate is " + xfa.layout.y(this));

I have tested this here and it works. I think the messgaeBox can be flakey for debugging.

Niall

View solution in original post

5 Replies

Avatar

Level 10

Hi,

Try it without the optional parameter "in" and see does it return the y coordinate in the default points.

I have used the layout.y in LC Designer ES2 without problems:

http://www.assuredynamics.com/index.php/category/portfolio/moving-objects-around-a-form/

https://acrobat.com/#d=Qjw-*VtT-gNdWjP*rlx2HA

Hope that helps,

Niall

Assure Dynamics

Avatar

Level 4

Niall,

I checked out your sample form. It has a positioned layout. But in fact that doesn't make a difference. I changed my layout to positioned as well and still get an error.

I also tried it without the optional parameter - same error:

xfa.host.messageBox(xfa.layout.y(this));

delivers an error.

I have a German version of the reader/acrobat. The error there says "Unterschiedliche Argumente im Eigenschaft- oder Funktionsargument".

That would translate to something like "different parameters in attribute-parameter or function-parameter" (it doesn't make much sense in German either ....)

I suppose what the error wants us to say is, that the function "y" does not expect an object as parameter. But that is exactly what the documentation calls for!

Uli

Avatar

Correct answer by
Level 10

Hi Uli,

I think the problem is using the messageBox to show the y-coordinate. Instead if you use the JavaScript Console with the following script. Press Control+J to open the console:

console.println("y-coordinate is " + xfa.layout.y(this));

I have tested this here and it works. I think the messgaeBox can be flakey for debugging.

Niall

Avatar

Level 10

Kürzen Sie das Ganze doch einfach mit xfa.host.messageBox(this.y) ab.

Alternativ geht auch

var Y = xfa.layout.y(this, "mm");

xfa.host.messageBox(Y.toString() + " mm")

Durch das Unwandeln des Ergebnisses in einen String, kommt es auch nicht mehr zu der Fehlermeldung in der Konsole.

Avatar

Level 4

Thank you all!

Both answers set me on track.

The following code works in fact:

if ((xfa.layout.y(myForm.myMasterpages.masterpage1.LineFooter) - xfa.layout.y(this)) < 150) {
    this.seperatingLine.presence = "hidden";
    }
else {
    this.seperatingLine.presence = "visible";
    }

This vaporizes a line if it comes too close to the page bottom.

Apparently I can do math with the result of "y" - but I have to convert it to a string to display it with messageBox. Strange behaviour in JavaScript, but that's the way it is.