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

JS to rotate field 90 degrees on multiple pages

asprague
Registered: Sep 10 2009
Posts: 6
Answered

I have created a batch process to add a form field (MyDate) that will print the date and time at 90 degrees, that is down the left hand margin. It does add the field to every page however, it only sets the orientation of the field for the first page to 90 degrees. All other pages remain at an orientation of 0 degrees.

Can anyone help explain what I need to do to set the orientation to 90 degrees on every page? Everything else seems to work. The script is as follows:

for (var p = 0; p < this.numPages; p++)
{
var fd = this.addField("MyDate", "text", p, [25,108,41,360]);
fd.rotation = 90;
fd.textSize=10;
fd.textFont = font.TimesBI;
fd.alignment = "left";
fd.fillColor = color.transparent;
fd.textColor = color.black;
fd.readonly = false;
fd.print = true;
fd.display = display.noView;
}

// add WillPrint script to populate the form field
this.setAction({cTrigger: "WillPrint", cScript: "var fld = this.getField(\"MyDate\"); fld.value = \"Document Printed on \" + util.printd(\"dd-mmm-yyyy, h:MM tt\",new Date()); \r"});

try67
Expert
Registered: Oct 30 2008
Posts: 2398
I think that because all the fields have the same name, you need to access each specific widget in order to change this property. You can read more about it in the reference file, but basically you need to add ".0", ".1", ".2" etc. to the field's name.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com