Indesign CC2015 duplicate page item

Hello, I’m a bit confused on how to get this done. I need to place an image on my page, then get the geometric bounds of that item, then duplicate it right next to the first placed image. Then another image as to be imported in that new box. This is part of a repeat loop. After all the images have been imported, they all have to be grouped then I’ll specify where to place the group on the page.

Here’s what I have so far…

set PlayersName to (text returned) of (display dialog "Nom" default answer "") as string

tell application "Adobe InDesign CC 2015"
	set MyDocument to active document
	tell application "Finder"
		set NumberLetters to (count of characters of PlayersName)
		set CompleteName to characters 1 thru -1 of PlayersName as list
		set MyLetter to items 1 thru -1 of CompleteName
	end tell
	tell MyDocument
		repeat with MyLetterX in MyLetter
			set PlaceLetter to ("Macintosh HD:Users:station_01:Desktop:Split_Letters:" & MyLetterX & ".pdf") as string
			place alias PlaceLetter on page 1
			set TheSize to get geometric bounds of FirstLetter
			set RectWidth to (item 4 of TheSize) - (item 2 of TheSize) as string
			move FirstLetter by {RectWidth + 0.0625, 0}
		end repeat
	end tell
end tell

Maybe I’m not clear enough!!

Hi. You have an undeclared variable in your code”FirstLetter. If you duplicate the rectangles, then all images should have the same dimensions, otherwise there may be a fitting problem that you need to address. Here is a way to set up the loop for place/dupe/move:

set imageList to choose file with multiple selections allowed --there must be at least two to loop

tell application "Adobe InDesign CS3"'s document 1
	set isTarget to ((place (imageList's item 1) on page 1)'s item 1)'s parent
	repeat with anAlias in (imageList's items 2 thru -1)
		tell ((place anAlias on duplicate isTarget)'s item 1's parent) to set {isTarget, theSize} to {it, geometric bounds}
		move isTarget by {(theSize's item 4) - (theSize's item 2) + 0.0625, 0}
	end repeat
end tell

Actually, the user input a name, let’s say HELLO. I have PDF’s named (A.pdf, B.pdf, C.pdf and so on…) I want Indesign to place each letters next to the other. Is what you wrote me will do that? It doesn’t need to be a duplicate of the first letter but can I place at a specific position?

So you mean to place only file H.pdf, E.pdf… O.pdf?

Since I don’t have your files, my code creates a pool of chosen images and then put them in the variable imageList. If you want to pull just typed letters, you need to populate the list. This would replace the first line of my code:

set folderPath to "Macintosh HD:Users:station_01:Desktop:Split_Letters:"
set imageList to {}
repeat with aLetter in ((display dialog "Nom" default answer "")'s text returned)'s items
	set imageList's end to alias (folderPath & aLetter & ".pdf")
end repeat

That worked great, thank you so much. Now I face the problem that I would like before the image duplicates, that the image is at 100% (size) and that the frame fit to content. I’m looking in the dictionary but I’m not sure how to handle that!

Because example, if I import an “I”, the “I” fits the frame of the letter that was there before wich is larger.

Can all the letters makes a group after they are all imported? Cause I want to move the whole word at a specific position in my document.

Fitting and scale are presented rather straightforwardly in the dictionary. The syntax is typically: command + object + parameter. fit is a command. isTarget, a rectangle, is the object. given frame to content is the desired parameter. You would set Horizontal and vertical scale, which have numbers as their parameter, and the desired number for both is 100.

You need to find (or create) a property that you can use as a target to make the group. I would probably use a label for that purpose, but there are syntax changes from my version and yours, and I haven’t used anything post CS3 in so long that I’ve forgotten the specifics. You should download and read one of Adobe’s scripting guides. Here is the one for CS6, which should work: