MacPython/InDesign
This wiki is in the process of being archived due to lack of usage and the resources necessary to serve it — predominately to bots, crawlers, and LLM companies. Edits are discouraged.
Pages are preserved as they were at the time of archival. For current information, please visit python.org.
If a change to this archive is absolutely needed, requests can be made via the infrastructure@python.org mailing list.
Only some snippets from a simple InDesign automator...
inD = app('Adobe InDesign CS2')
inD.script_preferences.user_interaction_level = k.never_interact
finder = app('Finder')
doc = inD.open(mactypes.Alias(u'/Users/user/Documents/test.indd'))
if doc.pages[page].side() == k.right_hand:
print "page %d is on the righthand side" % pageHow to place a text file and delete the first 2 lines:
story = doc.place(macpath, on=doc.pages[page], showing_options=False) story.lines[1:2].delete()
Fix the size of the new text frame:
rect = [76, 12, 284, 65]
# left, top, height, width in default unit (e.g. mm)
frame = story.text_frames[1].get()
frame.geometric_bounds.set(rect)
if frame.overflows():
# too much text -> increase size