These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

JavaScript in LifeCycle form - not accepting numeric value for x coord

cl5792
Registered: Jul 17 2008
Posts: 53
Answered

Can anyone tell me why this will work:

var NewPos = 250;
xfa.form.CMMSurvey.Page1.ModelType.ModelMarker.x = (NewPos + "pt");

but this will not (the x coordinate does not change):

var NewPos = xfa.form.CMMSurvey.Page1.MarkerValue.rawValue;
xfa.form.CMMSurvey.Page1.ModelType.ModelMarker.x = (NewPos + "pt");

The MarkerValue is a numeric field with a value of 280. This script is in the calculate event of the form. The NewPos variable in the second script does not seem to be recognized as a number. The ModelMarker object is a circle in a subform. The initial value of x is 36.

Thanks,

My Product Information:
LiveCycle Designer, Windows
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
Locations in PDF are determined by quad values not "x" & "y" values. There can also be an issue with rotated spaces in PDF. Please see the JS API Reference for your version of Acrobat.For a working example involving Redaction, [url=http://www.acrobatusers.com/tutorials/2008/07/auto_redaction_with_javascript/]Automating redaction with Acrobat JavaScript[/url] or [url=http://www.acrobatusers.com/tutorials/2007/10/auto_placement_annotations/]Automating placement of annotations[/url] both by Thom Parker, for examples on how locate locations in a PDF and adjust for a rotated page.

George Kaiser

cl5792
Registered: Jul 17 2008
Posts: 53
Thank you for the reply. However, I think I am looking for a different answer.

I am not working with annotations or a position within the page. The "x" property value of the shape object is it's relative position to the upper left corner of the subform containing it.

I can get the object to shift position correctly when I pass a variable of a specific number,

var NewPos = 250;
xfa.form.CMMSurvey.Page1.ModelType.ModelMarker.x = (NewPos + "pt");


but when I assign the variable the value of a numeric field it does not work.

var NewPos = xfa.form.CMMSurvey.Page1.MarkerValue.rawValue;
xfa.form.CMMSurvey.Page1.ModelType.ModelMarker.x = (NewPos + "pt");


I need help with determining why the numeric value of the field does not work in the script. I am wanting to move the object based on a value entered by the user. Is the data type different or something?

Thanks,
gkaiseril
Expert
Registered: Feb 23 2006
Posts: 4308
Is your form Dynamic?

From "Converting Acrobat® JavaScript for Use in LiveCycle™ Designer Forms" for the Acrobat JS "addField":

"Must use dynamic subforms in LiveCycle Designer along with hiding/unhiding the field. For example, this.presence = "visable" (or "invisible")."

George Kaiser

cl5792
Registered: Jul 17 2008
Posts: 53
Thank you so much. Setting saving the form as dynamic fixed it. :)