Highlighted

How to put text into a TextLine ?

Advocate ,
Nov 28, 2018

Copy link to clipboard

Copied

Dear friends,

In my 'graphic project' I want to place text into a TextLine. The following script gets some properties from a selected TextLine (which is located in an anchored frame). But so far I create an empty TextLIne at the desired place and with the desired angle.

But how to put text into it?

// Clone a selected TextLine to check the function

#target framemaker

  var j, oDoc = app.ActiveDoc, oFrame, oTextLine, CM = 1857713, DEGREE = 65536;

 

  oSelected = oDoc.FirstSelectedGraphicInDoc;

  oFrame = oSelected.FrameParent;

  oTextLine = oDoc.NewTextLine(oFrame);           // Take over specifications from selection

 

// there needs to be text to get the TextLine visible!

//oTextLine.AddText ("New text");                 // statement not valid

 

  oTextLine.Angle = 5 * DEGREE;

  oTextLine.BasePointX = oSelected.BasePointX;

  oTextLine.BasePointY = oSelected.BasePointY + 1*CM;

//oTextLine.Width = oSelected.Width;              // set by text contents ?

//oTextLine.Height= oSelected.Height

  oTextLine.Pen = oSelected.Pen;

  oTextLine.Color = oDoc.GetNamedColor("Magenta"); // ???

Obviously I need to define a text location - but how is this done in a TextLIne?

Adobe Community Professional
Correct answer by frameexpert | Adobe Community Professional

Hi Klaus,

You should be able to add text to a TextLine just like you do with a Paragraph:

var textLoc = new TextLoc (oTextLine, 0);

doc.AddText (textLoc, "Text on the text line.");

I haven't tested this with ExtendScript, but it should work.

Rick

TOPICS
Scripting

Views

180

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

How to put text into a TextLine ?

Advocate ,
Nov 28, 2018

Copy link to clipboard

Copied

Dear friends,

In my 'graphic project' I want to place text into a TextLine. The following script gets some properties from a selected TextLine (which is located in an anchored frame). But so far I create an empty TextLIne at the desired place and with the desired angle.

But how to put text into it?

// Clone a selected TextLine to check the function

#target framemaker

  var j, oDoc = app.ActiveDoc, oFrame, oTextLine, CM = 1857713, DEGREE = 65536;

 

  oSelected = oDoc.FirstSelectedGraphicInDoc;

  oFrame = oSelected.FrameParent;

  oTextLine = oDoc.NewTextLine(oFrame);           // Take over specifications from selection

 

// there needs to be text to get the TextLine visible!

//oTextLine.AddText ("New text");                 // statement not valid

 

  oTextLine.Angle = 5 * DEGREE;

  oTextLine.BasePointX = oSelected.BasePointX;

  oTextLine.BasePointY = oSelected.BasePointY + 1*CM;

//oTextLine.Width = oSelected.Width;              // set by text contents ?

//oTextLine.Height= oSelected.Height

  oTextLine.Pen = oSelected.Pen;

  oTextLine.Color = oDoc.GetNamedColor("Magenta"); // ???

Obviously I need to define a text location - but how is this done in a TextLIne?

Adobe Community Professional
Correct answer by frameexpert | Adobe Community Professional

Hi Klaus,

You should be able to add text to a TextLine just like you do with a Paragraph:

var textLoc = new TextLoc (oTextLine, 0);

doc.AddText (textLoc, "Text on the text line.");

I haven't tested this with ExtendScript, but it should work.

Rick

TOPICS
Scripting

Views

181

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
Nov 28, 2018 0
Adobe Community Professional ,
Nov 28, 2018

Copy link to clipboard

Copied

Hi Klaus,

You should be able to add text to a TextLine just like you do with a Paragraph:

var textLoc = new TextLoc (oTextLine, 0);

doc.AddText (textLoc, "Text on the text line.");

I haven't tested this with ExtendScript, but it should work.

Rick

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
Reply
Loading...
Nov 28, 2018 0
K.Daube LATEST
Advocate ,
Nov 28, 2018

Copy link to clipboard

Copied

Thank You, Rick!

The following works fine, ...

  oTextLoc = new TextLoc (oTextLine, 0);

  oDoc.AddText (oTextLoc, "New text");

... but i have not the simplest idea where the colour comes from:

Clone-TextLine1.png

The size and font etc. is from the original TextLine - but the source of the colour definition is unknown.

The original (selected) TextLine uses the character format Name which defines font family and weight - rest is AsIs. The size (22pt) is set locally.

Edit

I have found (object Data Browser) an undocumented attribute StyleTag which allows me to apply a character format:

  oTextLine.StyleTag = "fh2-fig-heading2";

For the time beeing this is sufficient information...

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
Reply
Loading...
Nov 28, 2018 0