Skip to main content
Inspiring
February 12, 2018
Answered

How do I rotate the text inside of a text field with JavaScript ?

  • February 12, 2018
  • 1 reply
  • 4832 views

Hi,

I'm using Acrobat Pro DC 2015 Release.  I created a text field (using this.addField) then I attempted to rotate the text using the rotation property.  I've tried rotations of 90,  180, and 270, but the text never rotates.  If I bring up the properties dialog for the text field, which has a "Orientation" pulldown menu under the General tab, I can easily rotate the text by 90, 180, and 270 degrees.

I know that the text box doesn't rotate, I only want to rotate the text inside of the text box.  I've tried this with two different text boxes in my program but I can never get the text to rotate.  When I look at the text box properties dialog, specifically the "Orientation" pulldown, it never reflects what my program is attempting to do -- it always stays at 0 degrees.

With any text field and as you know, there are numerous text properties one can set -- textFont, textColor, textSize, readonly, value, etc.  Is there some requirement whereby the rotation property has to be set AFTER all of the other properties have been set?  I've tried moving the rotation property around in my program relative to the other text properties, but I still can't get my text to rotate.

BTW, my page is in landscape mode.  I haven't done anything in my program to reflect this orientation -- do I need to do something to tell Acrobat my page is in landscape mode?

Thanks for any suggestions anyone has.

Dave

This topic has been closed for replies.
Correct answer try67

The page size is irrelevant. My guess is there's something wrong with your code. Can you share the code you used to do it, as well as the file? You can upload the file to a website like Dropbox, Google Drive, Adobe Cloud, etc., and then post the link to it here.


I created a file that demonstrates how to rotate a field, and how to read the field's current rotation: Field rotation test.pdf - Google Drive

1 reply

Bernd Alheit
Community Expert
February 12, 2018

What do you use to rotate the field?

DHeadrickAuthor
Inspiring
February 12, 2018

Hi Bernd,

As mentioned in my post, I'm using the rotation property.  For example, MyTextFieldVariable.rotation = 90

Is this correct?

Thanks.


Dave

try67
Community Expert
February 12, 2018

I'm still confused.  Let me ask a specific question.  What can I do programmatically to change the data displayed by the Orientation pulldown in the properties dialog?  Let's say I want the Orientation dialog to display 90 degrees.  I know how to set it to 90 degrees manually using the GUI.  What do I do in JavaScript so that the Orientation dialog will display 90 degrees?

The inverse should apply.  If I set the Orientation dialog to say 90 degrees using the GUI, how do I read this value in JavaScript?  What Javascript property reflects the value of Orientation that I set with the GUI?

So far, I haven't found a way programmatically to set or read the value displayed by the Orientation pulldown.  The Orientation GUI display and the value of the rotation property seem completely independent.  I can program rotation to any value I want and the Orientation dialog value never changes.  Is there any way programmatically that I can change what the Orientation pulldown displays?

Thanks again.


this.getField("Text1").rotation=90;