Creating InDesign Scripts With Python
We publish a lot of content related to InDesign scripts here at InDesignSecrets and in InDesign Magazine. And until now, nearly all the scripts we’ve written about were produced with either AppleScript or JavaScript. But recently it was brought to our attention by a developer named Lohrii Alo, that Windows users can also use Python to script InDesign. Lohrii has posted some sample scripts and an introductory article about using Python to script InDesign at Github. One of his examples shows how to use InDesign Server to create a web application that makes business cards.
Another example of using Python to manipulate InDesign is SimpleIDML, a Python library used by the French newspaper Le Figaro as part of an automated system to produce complex documents from components made of IDML (InDesign Markup Language) XML files. It’s certainly not for beginners, but it is an interesting example of how Python is being used in the real world to make InDesign files.
We’ll keep an eye out for more developments in the world of Python scripting related to InDesign!
Lohrii’s Windows solution is awesome, but I’m wishing dearly for the Mac equivalent. And a straightforward way to run the Python scripts from within InDesign itself. (I haven’t tried but it can probably be scripted in JS.) Should we add a UserVoice request for a full integration of Python into InDesign? The language has SEVERAL advantages over both JavaScript and AppleScript! Top of my list: it’s far easier to learn. (And after writing a few scripts: it has collections! dictionaries! lambda functions! a MASSIVE set of VERY useful libraries! of which the majority is FREE!)
Appscript is a high-level, user-friendly Apple event bridge that allows you to control AppleScriptable Mac OS X applications from Python.
https://pypi.python.org/pypi/appscript
It’s very interesting. Thank you for the article, Mike!
Thanks for that, Mike, looks very interesting.
I posted native Python support as a User Voice Feature Request here: https://indesign.uservoice.com/forums/601021-adobe-indesign-feature-requests/suggestions/32193772-add-python-to-the-list-of-supported-scripting-lang
Voted in favour!
Ditto!
I like this topic, though I don’t know much about using scripts or writing them. I am the person charged with making our non-profit’s membership roster for 2018-2020. So I have thought that using a script to format the text that includes an image of each person, their name, address, phone, email, yr joined, spouses name… I’d bring in the data from a thumb drive that the previous roster person made, but I’m a bit stumped on where to begin this journey. Any assistance would be greatly appreciated.
Should the data I’m importing be saved in a certain format? Are there free scripts for doing this? Can I set the type style? Size?
Thank you.
Do you really want such an extensive answer in these (small!) comment boxes? (Your question is also not really about Python, is it?) Better ask in the General Questions Forum. Follow the link in the top bar to the forums.
@KaCe No need for scripting. You can probably use Data Merge. Read the help files, or get a subscription to lynda.com (free trial!) and watch David Blatner’s “InDesign: Data merge and database publishing course.
Thank you for the information. I will get a Lynda.com subscription and will glean all I can from David Blatner’s merge and database publishing… it gives me a direction to head. I also can’t believe that I’m the only one who volunteers to do these things and then must figure it out. Your direction will give me a good start. Thanks again.