Créer un index dans indesign - PAO / Desktop Publishing - Graphisme
MarshPosté le 17-02-2006 à 00:34:38
Salut à tous, Je cherche à créer un index dans mon document dans indesign. Pour ça, j'ai récupéré un script, et je l'ai modifié ainsi :
tell application "Adobe InDesign CS2" tell active document -- Number of pages in the document - 2 set NumberOfPage_2 to count of pages -- in the same idea: number of spread(s) in the document
set myNameList to name of every page set myOffsetList to document offset of every page set myIndexList to index of every page
end tell try set myErrorMessage to "Ouvrez un document et recommencez." set myPub to active document set myText to "" set myList to {} set myAppliedStyle2 to "" tell myPub set myErrorMessage to "Pas de texte dans ce fichier" set myStories to object reference of stories set myErrorMessage to "Ne trouve pas le style de caractre demand" --ENTRER ICI LE STYLE RECHERCH vvvvvvvvvv set myIndexStyle to character style "Index" repeat with myCounter1 from 1 to count items of myStories set myErrorMessage to "Pas de Story !" set myStory to object reference of item myCounter1 of myStories repeat with myCounter from 1 to count (words of myStory) set myErrorMessage to "Ne trouve pas de mot" set myWord to object reference of word myCounter of myStory
tell myWord set myErrorMessage to "Ne trouve pas de style de caractre appliqu" set myAppliedStyle to applied character style
if myIndexStyle = myAppliedStyle then set myText to myText & myWord & " " end if
if myAppliedStyle2 = myIndexStyle then set myErrorMessage to "Trouve pas de parent !" set myParent to parent set myErrorMessage to "Trouve pas de parent au bloc de texte !" set myPage to parent of myParent set myErrorMessage to "Pas ne nom la page !" set myPageName to name of myPage
if myAppliedStyle2 \u2260 myAppliedStyle then set myText to myText & tab & myPageName & return set myErrorMessage to "Ne peut pas ajouter la chane de caractres !" set myList to myList & myText set myText to "" end if end if end tell set myAppliedStyle2 to myAppliedStyle end repeat end repeat end tell if myList = {} then set myErrorMessage to "Le style de caractre n'est appliqu nulle part" error else set myList to my mySort(myList) set myText to myList as string set myIndexPub to make document tell myIndexPub tell spread 1 make text frame with properties {geometric bounds:{"6p", "6p", "19p", "19p"}} set text of text frame 1 to myText end tell end tell end if on error activate display dialog myErrorMessage end try end tell
on mySort(my_list) set myErrorMessage to "Ne peut pas trier la liste !" set the index_list to {} set the sorted_list to {} repeat (the number of items in my_list) times set the low_item to "" repeat with i from 1 to (number of items in my_list) if i is not in the index_list then set this_item to item i of my_list as text if the low_item is "" then set the low_item to this_item set the low_item_index to i else if this_item comes before the low_item then set the low_item to this_item set the low_item_index to i end if end if end repeat set the end of sorted_list to the low_item set the end of the index_list to the low_item_index end repeat return the sorted_list end mySort
Le problème est que le numéro de page affiché dans l'index est toujours 1. Pouvez-vous m'expliquer pourquoi ? Merci.
Marsh Posté le 17-02-2006 à 00:34:38
Salut à tous,
Je cherche à créer un index dans mon document dans indesign. Pour ça, j'ai récupéré un script, et je l'ai modifié ainsi :
tell application "Adobe InDesign CS2"
tell active document
-- Number of pages in the document - 2
set NumberOfPage_2 to count of pages
-- in the same idea: number of spread(s) in the document
set myNameList to name of every page
set myOffsetList to document offset of every page
set myIndexList to index of every page
end tell
try
set myErrorMessage to "Ouvrez un document et recommencez."
set myPub to active document
set myText to ""
set myList to {}
set myAppliedStyle2 to ""
tell myPub
set myErrorMessage to "Pas de texte dans ce fichier"
set myStories to object reference of stories
set myErrorMessage to "Ne trouve pas le style de caractre demand"
--ENTRER ICI LE STYLE RECHERCH vvvvvvvvvv
set myIndexStyle to character style "Index"
repeat with myCounter1 from 1 to count items of myStories
set myErrorMessage to "Pas de Story !"
set myStory to object reference of item myCounter1 of myStories
repeat with myCounter from 1 to count (words of myStory)
set myErrorMessage to "Ne trouve pas de mot"
set myWord to object reference of word myCounter of myStory
tell myWord
set myErrorMessage to "Ne trouve pas de style de caractre appliqu"
set myAppliedStyle to applied character style
if myIndexStyle = myAppliedStyle then
set myText to myText & myWord & " "
end if
if myAppliedStyle2 = myIndexStyle then
set myErrorMessage to "Trouve pas de parent !"
set myParent to parent
set myErrorMessage to "Trouve pas de parent au bloc de texte !"
set myPage to parent of myParent
set myErrorMessage to "Pas ne nom la page !"
set myPageName to name of myPage
if myAppliedStyle2 \u2260 myAppliedStyle then
set myText to myText & tab & myPageName & return
set myErrorMessage to "Ne peut pas ajouter la chane de caractres !"
set myList to myList & myText
set myText to ""
end if
end if
end tell
set myAppliedStyle2 to myAppliedStyle
end repeat
end repeat
end tell
if myList = {} then
set myErrorMessage to "Le style de caractre n'est appliqu nulle part"
error
else
set myList to my mySort(myList)
set myText to myList as string
set myIndexPub to make document
tell myIndexPub
tell spread 1
make text frame with properties {geometric bounds:{"6p", "6p", "19p", "19p"}}
set text of text frame 1 to myText
end tell
end tell
end if
on error
activate
display dialog myErrorMessage
end try
end tell
on mySort(my_list)
set myErrorMessage to "Ne peut pas trier la liste !"
set the index_list to {}
set the sorted_list to {}
repeat (the number of items in my_list) times
set the low_item to ""
repeat with i from 1 to (number of items in my_list)
if i is not in the index_list then
set this_item to item i of my_list as text
if the low_item is "" then
set the low_item to this_item
set the low_item_index to i
else if this_item comes before the low_item then
set the low_item to this_item
set the low_item_index to i
end if
end if
end repeat
set the end of sorted_list to the low_item
set the end of the index_list to the low_item_index
end repeat
return the sorted_list
end mySort
Le problème est que le numéro de page affiché dans l'index est toujours 1. Pouvez-vous m'expliquer pourquoi ?
Merci.