Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to get the text box bounds using java script?

Community Beginner ,
Sep 27, 2019 Sep 27, 2019

textLayer.bounds returns the bounding box area of text which is based on current text. Instead of current text's bounding box area how to get the size of text box (dotted rectangle area) from script?

 

Untitled.pngexpand image

 

 

TOPICS
Actions and scripting
1.1K
Translate
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 2 Correct answers

LEGEND , Sep 27, 2019 Sep 27, 2019

Have you tried TextItem.height and TextItem.width?

 

Translate
Community Expert , Sep 27, 2019 Sep 27, 2019

As Lumigraphics mentioned, textItem.width and textItem.height work, but it displays in whatever you have your type units set to in the preferences, so you will need to convert to pixels, if that's what you want. And if you have your type units set to pixels, it will give a false reading of pixels, if you don't have the document's resolution set to 72ppi.

Translate
Adobe
LEGEND ,
Sep 27, 2019 Sep 27, 2019

Have you tried TextItem.height and TextItem.width?

 

Translate
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
Community Beginner ,
Sep 29, 2019 Sep 29, 2019
LATEST
Hi Lumigraphics, Thanks. With TextItem.height and TextItem.width i can able to get the exact width and height of text box. Is there any way to get X and Y of text box? I could not find any document reference except textLayer.bounds.
Translate
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
Community Expert ,
Sep 27, 2019 Sep 27, 2019

As Lumigraphics mentioned, textItem.width and textItem.height work, but it displays in whatever you have your type units set to in the preferences, so you will need to convert to pixels, if that's what you want. And if you have your type units set to pixels, it will give a false reading of pixels, if you don't have the document's resolution set to 72ppi.

Translate
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