Article View: adobe.scripting.indesign
Article #14723[AS] Doing a search for items on a page...
From: McKinley_Media
Date: Mon, 19 Jan 2004 12:57
Date: Mon, 19 Jan 2004 12:57
85 lines
3705 bytes
3705 bytes
I'm creating tabs on the side of each page on a document (yes, I've got more questions).
I'm doing a search of my document for items matching a particular paragraph style. I'm then generating the text that shows the categories on that page.
I have this working except when a category is the first thing on a page. In that case, the span that should be on the tab can't include the last item from the previous page.
How do I recognize when an item is the first thing on a page without changing the way I'm looking for the page numbers of the items? (I can change them, if I need to, it's just hard to throw away that work).
Here's a parred down version of the code I have:
tell application "InDesign CS"
set find preferences to nothing
set change preferences to nothing
set myCstyle to character style "[No character style]" of active document
set myPstyle to paragraph style "County" of myDoc
tell myDoc
set theResult to search with find attributes {applied paragraph style:myPstyle}
end tell
set myPage to 0
set myResultIndex to 2
set myFirstCountyChange to 1
repeat with myPage from 1 to (the number of pages in myDoc)
if myLastCounty is not equal to "" then
set myFirstCounty to myLastCounty
end if
set myLastCounty to ""
set myPstyle to paragraph style "CountyTab" of myDoc
if myPage is 1 then
set myFirstCounty to item 1 of theResult
end if
if myFirstCountyChange = 1 then
set myTitle1 to ""
end if
if myResultIndexDone is not equal to "yes" then
set myPageRef to (name of parent of parent text frame of item myResultIndex of theResult) as number
if myPageRef = myPage then
set myTitle2 to ""
set done to "no"
repeat while done = "no"
if myResultIndex = (number of items in theResult) then
set done to "yes"
set myResultIndexDone to "yes"
else
if (name of parent of parent text frame of item (myResultIndex + 1) of theResult) as number = myPage then
set myResultIndex to myResultIndex + 1
else
set done to "yes"
end if
end if
end repeat
set myFirstCountyChange to 1
set myLastCounty to item myResultIndex of theResult
set myTitle to myTitle1 & " to " & myTitle2 & "County"
end if
end if
tell page myPage of myDoc
set myTabFrame to make text frame
set text of myTabFrame to myTotalVert
end tell
if myPage mod 2 = 1 then
if myPage = 1 then
tell page myPage of myDoc
set geometric bounds of myTabFrame to {".375i", "8.1i", "10.625i", "8.375i"}
end tell
else
tell page myPage of myDoc
set geometric bounds of myTabFrame to {".375i", "16.6i", "10.625i", "16.875i"}
end tell
end if
else
tell page myPage of myDoc
set geometric bounds of myTabFrame to {".375i", ".08i", "10.625i", ".375i"}
end tell
end if
set applied paragraph style of text of myTabFrame to myPstyle
if myResultIndexDone is not equal to "yes" then
set myResultIndex to myResultIndex + 1
end if
end repeat
end tell
Technical Details
Message-ID:
<2ccf7264.-1@webx.la2eafNXanI>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!webxShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f939a,eacf863bee28a67c,start X-Google-Attributes: gidf939a,public X-Google-ArrivalTime: 2004-01-19 05:07:38 PST From: McKinley_Media@adobeforums.com Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!webx Newsgroups: adobe.scripting.indesign Subject: [AS] Doing a search for items on a page... Message-ID: <2ccf7264.-1@webx.la2eafNXanI> Date: Mon, 19 Jan 2004 04:57:22 -0800 Lines: 99 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit