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

How can I use refer to or use width and height of other object?

New Here ,
Nov 17, 2017 Nov 17, 2017

Copy link to clipboard

Copied

I'm currently working on this code

var doc = app.activeDocument; 

var textRef1 = doc.textFrames.pointText([300,1000]);

textRef1.contents = "First para text \rFirst para text \rFirst para text \rFirst para text  \rFirst para text";

var textRef2 = doc.textFrames.pointText();

textRef2.contents = "Second para text"; 

The code is simple just to create point text or maybe rectangle or texframe below "textRef1". But I don't know how to get height and width value of "textRef1"

Later I will have to create rectangle background as well so I really have to know those value.

Can you please teach me how to do it?

TOPICS
Scripting

Views

326

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

Community Expert , Nov 18, 2017 Nov 18, 2017

Try this:

var doc = app.activeDocument;

var textRef1 = doc.textFrames.pointText([300,-300]);

textRef1.contents = "First para text \rFirst para text \rFirst para text \rFirst para text  \rFirst para text";

var Rect = doc.pathItems.rectangle(textRef1.top, textRef1.left, textRef1.width, textRef1.height);

Rect.stroked = true;

Rect.filled = false;

Rect.move(textRef1, ElementPlacement.PLACEAFTER);

But be sure, there are differences between pointtext and areatext.

Have fun

Votes

Translate

Translate
Adobe
Community Expert ,
Nov 18, 2017 Nov 18, 2017

Copy link to clipboard

Copied

Try this:

var doc = app.activeDocument;

var textRef1 = doc.textFrames.pointText([300,-300]);

textRef1.contents = "First para text \rFirst para text \rFirst para text \rFirst para text  \rFirst para text";

var Rect = doc.pathItems.rectangle(textRef1.top, textRef1.left, textRef1.width, textRef1.height);

Rect.stroked = true;

Rect.filled = false;

Rect.move(textRef1, ElementPlacement.PLACEAFTER);

But be sure, there are differences between pointtext and areatext.

Have fun

Votes

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
New Here ,
Nov 19, 2017 Nov 19, 2017

Copy link to clipboard

Copied

LATEST

Yeah its work! Thank you so much

Votes

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