Das war eine der kniffligsten Skript-Aufgaben, die mir bisher hier gestellt wurden.
Wie immer nur als AppeScript.
Es kann mit den Ausrichtungen "Zum Bund" und "Vom Bund" umgehen.
Es erstellt neue einzelseitige Musterseiten und wendet diese an.
Es geht davon aus, dass das Dokument mit einer rechten Seite anfängt und dass keine Druckbogeninseln eingerichtet wurden.
Wie immer ohne Gewähr und nur nach vorherigem Speichern zu verwenden (ich hab sogar darüber nachgedacht, den Speichern-Befehl sicherheitshalber mit einzubauen.)
Martin, das Script hat zwei Subroutinen, die ich für praktisch halte. Vielleicht hast du Zeit und Lust, diese mal zu testen:
- revertDoc() führt solange Undo aus, bis es nicht mehr geht. Ich habe in der Referenz keinen Befehl für "Revert to saved" gefunden und diese Subroutine kann das ersetzen.
- getPage() nimmt ein Object entgegen und sollte die Seite ausspucken, auf der das Objekt liegt.
Feedback, ob das in die richtige Richtung geht, nehme ich gern an.
Ausbauwünsche nur vielleicht ;)
tell application "Adobe InDesign CS2"
set aDoc to active document
set nDSpreads to count spreads in aDoc
repeat with p from 1 to nDSpreads
if (count pages in spread p of aDoc) is not 2 then
if ((count pages in spread p of aDoc) is 1) and (p = 1 or p = nDSpreads) then
-- erste und letzte Seite darf einzeln stehen
else
display dialog "Sie haben mindestens eine Druckbogeninsel. Damit funktioniert das Skript nicht."
return
end if
end if
if (count pages in spread 1 of aDoc) is not 1 then
display dialog "Das Skript geht davon aus, dass die erste Seite einzeln steht."
return
end if
end repeat
set find preferences to nothing
set justification of find preferences to away from binding side
set foundThis to search
repeat with f from 1 to count foundThis
set firstC to first item of parent text frames of item f of foundThis
set aPage to my getPage(firstC)
set cPage to class of parent of aPage
if cPage is master spread then
if (index of aPage) mod 2 = 0 then
set justification of item f of foundThis to right align
else
set justification of item f of foundThis to left align
end if
else
if (document offset of aPage) mod 2 = 1 then
set justification of item f of foundThis to right align
else
set justification of item f of foundThis to left align
end if
end if
end repeat
set find preferences to nothing
set justification of find preferences to to binding side
set foundThis to search
repeat with f from 1 to count foundThis
set firstC to first item of parent text frames of item f of foundThis
set aPage to my getPage(firstC)
set cPage to class of parent of aPage
if cPage is master spread then
if (index of aPage) mod 2 = 1 then
set justification of item f of foundThis to right align
else
set justification of item f of foundThis to left align
end if
else
if (document offset of aPage) mod 2 = 0 then
set justification of item f of foundThis to right align
else
set justification of item f of foundThis to left align
end if
end if
end repeat
set prevLayoutAdjustments to enable layout adjustment of layout adjustment preferences of aDoc
set enable layout adjustment of layout adjustment preferences of aDoc to true
set saveMargins to {}
set nSpreads to count master spreads of aDoc
repeat with m from 1 to nSpreads
set nMPages to count pages of master spread m of aDoc
repeat with n from 1 to nMPages
set tempMargin to margin preferences of page n of master spread m of aDoc
copy (top of tempMargin & left of tempMargin & bottom of tempMargin & right of tempMargin) as list to the end of saveMargins
end repeat
end repeat
set nPages to count pages of aDoc
repeat with n from 1 to nPages
set tempMargin to margin preferences of page n of aDoc
copy (top of tempMargin & left of tempMargin & bottom of tempMargin & right of tempMargin) as list to the end of saveMargins
end repeat
set facing pages of document preferences of aDoc to false
set saveCounter to 1
repeat with m from 1 to nSpreads
set nMPages to count pages of master spread m of aDoc
repeat with n from 1 to nMPages
set tempValuesMargin to item saveCounter of saveMargins
set saveCounter to saveCounter + 1
set tempMargins to (a reference to margin preferences of page n of master spread m of aDoc)
if n mod 2 = 0 then
set top of tempMargins to item 1 of tempValuesMargin
set left of tempMargins to item 2 of tempValuesMargin
set bottom of tempMargins to item 3 of tempValuesMargin
set right of tempMargins to item 4 of tempValuesMargin
else
set top of tempMargins to item 1 of tempValuesMargin
set right of tempMargins to item 2 of tempValuesMargin
set bottom of tempMargins to item 3 of tempValuesMargin
set left of tempMargins to item 4 of tempValuesMargin
end if
end repeat
end repeat
repeat with m from 1 to nMPages
set oldMP to master spread m of aDoc
set hey to name of oldMP
if (count pages of oldMP) = 2 then
set nuMP to duplicate master spread m of aDoc
set base name of nuMP to base name of oldMP & "-rechts"
delete page 2 of master spread m of aDoc
delete page 1 of nuMP
end if
end repeat
repeat with n from 1 to nPages
set tempValuesMargin to item saveCounter of saveMargins
set saveCounter to saveCounter + 1
set tempMargins to (a reference to margin preferences of page n of aDoc)
if n mod 2 = 1 then
set appliedMaster to name of applied master of page n of aDoc
set toBeApplied to (master spread ((appliedMaster & "-rechts") as string) of aDoc)
set applied master of page n of aDoc to toBeApplied
set top of tempMargins to item 1 of tempValuesMargin
set left of tempMargins to item 2 of tempValuesMargin
set bottom of tempMargins to item 3 of tempValuesMargin
set right of tempMargins to item 4 of tempValuesMargin
else
set toBeApplied to applied master of page n of aDoc
set applied master of page n of aDoc to toBeApplied
set top of tempMargins to item 1 of tempValuesMargin
set right of tempMargins to item 2 of tempValuesMargin
set bottom of tempMargins to item 3 of tempValuesMargin
set left of tempMargins to item 4 of tempValuesMargin
end if
end repeat
set enable layout adjustment of layout adjustment preferences of aDoc to prevLayoutAdjustments
-- my revertDoc()
end tell
on getPage(someThing)
tell application "Adobe InDesign CS2"
set myTextObjects to {text, word, text style range, line, paragraph}
set myTextAtoms to {insertion point, character}
set myPage to someThing
if class of someThing is in myTextAtoms then
set myPage to parent text frame of someThing
else if class of someThing is in myTextObjects then
set myPage to parent text frame of first character of someThing
end if
repeat until (class of myPage) is page
try
set myPage to parent of myPage
on error
return -1
end try
end repeat
return myPage
end tell
end getPage
on revertDoc()
tell application "Adobe InDesign CS2"
set done to false
repeat until done
try
undo active document
on error
set done to true
end try
end repeat
end tell
end revertDoc