Skip to main content
November 4, 2011
Answered

Place text frame on the linked image...!

  • November 4, 2011
  • 1 reply
  • 3357 views

Hi Everyone!

Its possible to place text frame on the linked image using java script.

the text frame text is name of the linked image. anyone to help me if possible...?


Thanks in advance.

-yajiv



This topic has been closed for replies.
Correct answer Ten A

Hi, I rewrite this one,

var tgt = app.activeDocument.rectangles;

for (i=0;i<tgt.length;i++){

    myCaption = app.activeDocument.textFrames.add();

    myCaption.textFramePreferences.verticalJustification =

        VerticalJustification.BOTTOM_ALIGN

    myCaption.contents = tgt.graphics[0].itemLink.name

    myCaption.paragraphs[0].justification =

        Justification.CENTER_ALIGN;

    bnds = tgt.visibleBounds;

    myCaption.visibleBounds =

        [bnds[0]-6, bnds[1], bnds[0]-1,bnds[3]];

    }

How about it?

Ten

1 reply

Ten A
Community Expert
Community Expert
November 5, 2011

Hi, Try this one.

var slct = app.activeDocument.selection[0];

var sourceFolder = "/"; //set images path

var fNm ="";

if (slct=="[object TextFrame]") {

    fNm = sourceFolder + slct.contents;

    var f = new File (fNm);

    if(f.exists){

        slct.contents = "";

        slct.place(f);

        slct.fit(FitOptions.PROPORTIONALLY);

        slct.fit(FitOptions.CENTER_CONTENT);

        }

    }

You can choose images path to set "sourceFolder" variable. But TextFrames contents contain full-path of Image files, remove sourceFolder variable and set fNm like below:

fNm = slct.contents;

Ten

November 5, 2011

Hi Ten,

Thansk for your reply.

it is not working. i need blow mentioned step to script.

In new document has two image was placed. If i run the script

  • The text frame is placed above linked image. the text frame content is name of linked image.
  • The text frame aligned centre of the placed image.

It's possible...?

Help me......!

-yajiv

Ten A
Community Expert
Ten ACommunity ExpertCorrect answer
Community Expert
November 7, 2011

Hi, I rewrite this one,

var tgt = app.activeDocument.rectangles;

for (i=0;i<tgt.length;i++){

    myCaption = app.activeDocument.textFrames.add();

    myCaption.textFramePreferences.verticalJustification =

        VerticalJustification.BOTTOM_ALIGN

    myCaption.contents = tgt.graphics[0].itemLink.name

    myCaption.paragraphs[0].justification =

        Justification.CENTER_ALIGN;

    bnds = tgt.visibleBounds;

    myCaption.visibleBounds =

        [bnds[0]-6, bnds[1], bnds[0]-1,bnds[3]];

    }

How about it?

Ten