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
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
...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
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
It's possible...?
Help me......!
-yajiv
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
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
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
Copy link to clipboard
Copied
Hi Ten,
Its awesome...!!!
also its possible to get subfolder files....?
-yajiv.
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
}
} else {
myList += myFiles.name + "\n";
}
}
alert(myList);
It checks first child of current folder.
Ten.
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
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
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
Copy link to clipboard
Copied
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