Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


Possible or Not: Batch Rect with Hierarchal Fields

Engaged ,
Aug 24, 2021 Aug 24, 2021

Copy link to clipboard

Copied

I'm trying to move fields using the rect property, but it doesn't seem to want to move multiple fields. I was trying to come up with a loop that would use an array of all child fields, but I'm not getting what I want. Is this even possible?

var oParent = this.getField("my.field.name");
var getStr = 'this.getField("';
var aChildren = oParent.getArray();
for(i in aChildren) {
	var fldName = getStr + aChildren[i].name + '")';
	var bRect;
	var aRect = bRect + i;
	aRect = fldName.rect;
	aRect[0] -= 24;
	aRect[2] -=  24;
	fldName.rect = aRect;
}

I have several variations of the code above. This is one of them. The console was returning [object field]my.field.name.children but not this.getField("my.field.name.children);

It also doesn't seem to care about the rect property. I've also tried the simple coding for rect and am not able to get parent fields to perform rect. The console returns InValidGetError: Get not possible, invalid or unknown.

I want all fields affected to do the same thing regardless of original xyxy coordinates. I was assuming that I couldn't utilize the rect property on multiple hierarchal fields at the same time, but then I wondered if I could get an array of all children, return the object name, then add .rect to each iteration and perform the same rect each time it goes through the loop...

TOPICS
Create PDFs, JavaScript, PDF forms

Views

43

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Adobe Community Professional , Aug 24, 2021 Aug 24, 2021
It's certainly possible, but your code doesn't make sense, especially the part where you're trying to access the fields. If they are all a part of a group that is called "my.field.name" then all you need to do is this: var oParent = this.getField("my.field.name"); var aChildren = oParent.getArray(); for (var i in aChildren) { var f = aChildren[i]; var aRect = f.rect; aRect[0] -= 24; aRect[2] -= 24; f.rect = aRect; }

Likes

Translate

Translate
Adobe Community Professional ,
Aug 24, 2021 Aug 24, 2021

Copy link to clipboard

Copied

fldName.rect

will not work because fldName is not a field object. 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Aug 24, 2021 Aug 24, 2021

Copy link to clipboard

Copied

It's certainly possible, but your code doesn't make sense, especially the part where you're trying to access the fields.

If they are all a part of a group that is called "my.field.name" then all you need to do is this:

 

 

var oParent = this.getField("my.field.name");
var aChildren = oParent.getArray();
for (var i in aChildren) {
	var f = aChildren[i];
	var aRect = f.rect;
	aRect[0] -= 24;
	aRect[2] -=  24;
	f.rect = aRect;
}

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Aug 26, 2021 Aug 26, 2021

Copy link to clipboard

Copied

LATEST

Thank you. I couldn't get it to work in the file I was working in, but it works perfectly in a test page I created. I don't know what the issue was, but I kept getting the InvalidGetError message. It was a similar script to others I had tried.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines