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

Place text frame on the linked image...!

Guest
Nov 04, 2011 Nov 04, 2011

Copy link to clipboard

Copied

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



TOPICS
Scripting

Views

3.0K

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 07, 2011 Nov 07, 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

...

Votes

Translate

Translate
Community Expert ,
Nov 05, 2011 Nov 05, 2011

Copy link to clipboard

Copied

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

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
Guest
Nov 05, 2011 Nov 05, 2011

Copy link to clipboard

Copied

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

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
Community Expert ,
Nov 07, 2011 Nov 07, 2011

Copy link to clipboard

Copied

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

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
Guest
Nov 07, 2011 Nov 07, 2011

Copy link to clipboard

Copied

Hi Ten.

Thanks Ten..!

This script i want. Once again thank for you support...

One doubt can you clarify that...

I'm working in MAC platform. If there is any possibility to search filename from server using javascript.

-yajiv

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
Community Expert ,
Nov 08, 2011 Nov 08, 2011

Copy link to clipboard

Copied

Servers mounts under "/Volumes". When you mount directory name of "public", you can access below

/Volumes/public/

And you can get file list below:

var myFolder = new Folder("/Volumes/public/");

var myFiles = myFolder.getFiles();

var myList = "";

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

    myList += myFiles.name + "\n";

    }

alert(myList);

Ten

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
Guest
Nov 08, 2011 Nov 08, 2011

Copy link to clipboard

Copied

Hi Ten,

Its awesome...!!!

also its possible to get subfolder files....?

-yajiv.

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
Community Expert ,
Nov 08, 2011 Nov 08, 2011

Copy link to clipboard

Copied

We can use File's "creator" property to determin File or Folder.

If target object is "File" then return creator string, but target object is "Folder", in this case return "undefined".

var myFolder = new Folder("/Volumes/public/");

var myFiles = myFolder.getFiles();

var myList = "";

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

    if(myFiles.creator==undefined){

        myFiles2= myFiles.getFiles();

        for (j=0;j<myFiles2.length;j++){

            myList += myFiles.name +

                "/" + myFiles2.name + "\n";

            }

        } else {

            myList += myFiles.name + "\n";

            }

    }

alert(myList);

It checks first child of current folder.

Ten.

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
Guest
Nov 09, 2011 Nov 09, 2011

Copy link to clipboard

Copied

Ten,

Chance less...... you rock..!!!

Thanks you support....!. its really helpful and Thanks lot....

It's possible to search filename in subfolder....?

Ten, Do you have any reference document javascript(.jsx) (or) any website name for java script reference.

Please let me inform.

Thanks for Cheers!!!

- yajiv

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
Guest
Nov 10, 2011 Nov 10, 2011

Copy link to clipboard

Copied

Hi Ten,

     Finally I modify your code to get search filename from Subfolders.

Here the code...

var myFolder = new Folder("A:\Workout/Indesign/Automation/");

var myFiles = myFolder.getFiles();

var myList = "";

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

        if(myFiles.creator==undefined){

            var myFiles2= myFiles.getFiles();

                for (j=0;j<myFiles2.length;j++){

                    if(myFiles2.creator==undefined){

                        var myFiles3= myFiles2.getFiles();

                        for (k=0;k<myFiles3.length;k++){

                            //myList += myFiles.name + "/" + myFiles2.name+ "/" + myFiles3.name + "\n";

                                if(myFiles3.name=="sample.tif")

                                    var myfile="File found - "+myFiles.name + "/" + myFiles2.name+ "/" + myFiles3.name;

                                else

                                     var myfile="File not found"

                                    }

                                }

                            }

                        }

                    }

alert(myfile);

Thanks Ten!!!

you are legend....!!!

- yajiv

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
Community Expert ,
Nov 11, 2011 Nov 11, 2011

Copy link to clipboard

Copied

Hi, yajiv.

If you want search more deeper, using recursive function is better way.

Sample script is below:

var myFolder = new Folder("/Volumes/public/agata");

alert (getFiles(myFolder));

function getFiles (obj) {

    var str = "";

    var myList = obj.getFiles();

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

        if (myList.creator!=undefined) {

            str += myList.fullName + "\n";

            } else {

                str += getFiles(myList) + "\n";

                }

        }

    return str;

    }

and... http://forums.adobe.com/thread/668578 as reference

Ten

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
Guest
Nov 11, 2011 Nov 11, 2011

Copy link to clipboard

Copied

LATEST

Hi Ten,

It's awesome script....

you are really Gr8!!! .I complicate small things to big. this script ia really help me further innovation.

Thanks friend!!!

with friendly,

- yajiv

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