🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: adobe.scripting.indesign
11 messages
11 total messages Started by Pat_R._Oneill Fri, 13 Feb 2009 15:53
Positioning Inline images? [CS3 JS WIN]
#1272
Author: Pat_R._Oneill
Date: Fri, 13 Feb 2009 15:53
1 lines
1007 bytes
I have an inline graphic in a line of text. I want to be able to automatically position it in the vertical center of the line, but i can't find anyway to do this in javascript. Ive tried geometric and visible bounds to no avail. Ive also tried looking for a way to change it in indesign, but it only seems to be possible by dragging it with the mouse. Any ideas?
Re: Positioning Inline images? [CS3 JS WIN]
#1276
Author: Dave_Saunders
Date: Fri, 13 Feb 2009 17:25
10 lines
836 bytes
Use a move.

Something like this:

myGBs = myInline.geometricBounds;
myCenterY = (myGBs[2] + myGBs[0])/2;
myBaseline = myInline.parent.baseline;
myInline.move(undefined, [0, myBaseline - myCenterY);

Dave
Re: Positioning Inline images? [CS3 JS WIN]
#1277
Author: The Bullitt
Date: Fri, 13 Feb 2009 17:44
9 lines
845 bytes
Dave

I have a related problem. I'm not familiar with scripts but need one that would search a story and, e.g., replace the text "Pencil.tif" with a graphic file named Pencil.tif in a given folder.

Can you help with this?

Thanks,

Tom
Re: Positioning Inline images? [CS3 JS WIN]
#1279
Author: Kasyan_Servetsky
Date: Fri, 13 Feb 2009 18:36
25 lines
1540 bytes

      need one that would search a story and, e.g., replace the text "Pencil.tif"
      with a graphic file named Pencil.tif from a given folder.




I've found in my archive a script written by Peter Kahrel (I modified it a little). It finds text between two @ characters – e.g. @Pencil.tif@ – and replaces it with image that has the same name and is in the root folder of C drive.

// reset the Find/Change dialog
app.findGrepPreferences = app.changeGrepPreferences = null;
// formulate a grep search string
app.findGrepPreferences.findWhat = '@.+?@';
// find all occurrence, last one first
f = app.activeDocument.findGrep (true);
for (i = 0; i < f.length; i++)
   {
   // construct file name
   name = f[i].contents.replace (/@/g, '');
   // place the pdf
   f[i].insertionPoints[0].place (File ('/c/' + name));
   }
// delete all @??@ codes
app.activeDocument.changeGrep()
Re: Positioning Inline images? [CS3 JS WIN]
#1287
Author: The Bullitt
Date: Fri, 13 Feb 2009 21:41
5 lines
696 bytes
Kasyan

Forgot to mention I'm working in original CS version. Grep probably won't work?

Tom
Re: Positioning Inline images? [CS3 JS WIN]
#1288
Author: Kasyan_Servetsky
Date: Fri, 13 Feb 2009 22:16
8 lines
694 bytes

      Grep probably won't work?




Certainly it won't &#8211; Grep is supported since CS3.
Re: Positioning Inline images? [CS3 JS WIN]
#1098
Author: The Bullitt
Date: Mon, 16 Feb 2009 15:23
1 lines
616 bytes
Time to upgrade?
Re: Positioning Inline images? [CS3 JS WIN]
#1110
Author: Harbs
Date: Tue, 17 Feb 2009 07:37
13 lines
1166 bytes
You can get the same result in CS2, but it's a lot more convoluted.

The basic idea is to build an array of the exact file name strings. To 
do this you use js RegEx to search the contents of every story. The 
results of this match() will give you the strings you need. You then 
iterate through your array and do a search() on your doc to do the 
replacements.

I think Peter's book on scripting InDesign has examples of this method.

-- 
Harbs
http://www.in-tools.com
Re: Positioning Inline images? [CS3 JS WIN]
#1113
Author: Peter Kahrel
Date: Tue, 17 Feb 2009 10:23
32 lines
1549 bytes
The good old days, eh, Harbs? Here's a CS2 version. It skips footnotes (because you can't do this kind of thing in footnotes in CS2) and tables.

Peter



#target indesign

picture_dir = '/d/' 
app.findPreferences = app.changePreferences = null; 
myStories = app.activeDocument.stories; 
for (i = 0; i < myStories.length; i++) 
   { 
   picnames = myStories[i].contents.match (/@.+?@/g); 
   if (picnames != null) 
      { 
      for (j = 0; j < picnames.length; j++) 
         { 
         found = app.activeDocument.search (picnames[j],false,false); 
         for (k = found.length-1; k > -1; k--) 
            { 
            try 
               { 
               filename = found[k].contents.replace (/@/g, ""); 
               found[k].insertionPoints[-1].place (File (picture_dir + filename)); 
               found[k].remove(); 
               } 
            catch(_){} 
            } 
         } 
      } 
   }
Re: Positioning Inline images? [CS3 JS WIN]
#1128
Author: Harbs
Date: Tue, 17 Feb 2009 20:48
9 lines
904 bytes
Peter Kahrel wrote:
> The good old days, eh, Harbs?

Yeah. ;) My problem is, that I still need to support CS2, so I'm still 
stuck using these backwards methods on occasion. :(

-- 
Harbs
http://www.in-tools.com
Re: Positioning Inline images? [CS3 JS WIN]
#1177
Author: Pat_R._Oneill
Date: Wed, 18 Feb 2009 19:09
3 lines
762 bytes
Took a little messing around with my current situation (its not always centered - sometimes a little off) but the move worked perfectly!

Thank you Dave
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads