├── .gitignore ├── test_template.indd ├── test_template.indt ├── Printmaster.scpt └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | docs/* 2 | -------------------------------------------------------------------------------- /test_template.indd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpfinley/printmaster/HEAD/test_template.indd -------------------------------------------------------------------------------- /test_template.indt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpfinley/printmaster/HEAD/test_template.indt -------------------------------------------------------------------------------- /Printmaster.scpt: -------------------------------------------------------------------------------- 1 | tell application "Adobe InDesign CS4" 2 | 3 | -- TODO: Ask for template document interactively. Something like: 4 | -- set myDocument to choose file with prompt "Please select the InDesign Template file" 5 | 6 | -- Open the InDesign Template file (.indt) 7 | set myDocument to open "Macintosh HD:Users:some:path:to:test_template.indt" 8 | 9 | -- Set up the InDesign view to show the XML sidebar and all of the good stuff. 10 | tell myDocument 11 | tell XML view preferences 12 | set show attributes to true 13 | set show structure to true 14 | set show tagged frames to true 15 | set show tag markers to true 16 | set show text snippets to true 17 | end tell 18 | 19 | -- Map the paragraph styles to the XML document. This must be done before the XML is imported. 20 | -- Big thanks to Phillip @ http://macscripter.net/viewtopic.php?id=18112 21 | set PStyleCount to (get count of paragraph styles) 22 | repeat with p from 1 to PStyleCount 23 | set thisPStyle to paragraph style p 24 | set thisPStyleObject to object reference of thisPStyle 25 | set thisPStyleName to name of thisPStyleObject as string 26 | --Avoids this error: The tag you are trying to create has an invalid name. 27 | if thisPStyleName is not "[Basic Paragraph]" and thisPStyleName is not "[No Paragraph Style]" then 28 | set XMLImportMap to make XML import map with properties {mapped style:thisPStyle, markup tag:thisPStyleName} 29 | end if 30 | end repeat 31 | 32 | -- TODO: Get markdown document interactively 33 | -- TODO: Convert markdown to XML 34 | 35 | -- Takes the XML source file and loads it into our blank test_template.indt 36 | import XML from "Macintosh HD:Users:some:path:to:source.xml" 37 | 38 | -- TODO: Place the XML into the document automatically 39 | -- Currently one must drag the `XML` node from the sidebar onto the text 40 | -- frame from within InDesign to populate the page with the document's content. 41 | -- Ideally, this would be done in AppleScript, but I haven't been able to figure this out. 42 | 43 | -- TODO: Execute this whole thing with a command from within Textmate 44 | 45 | end tell -- myDocument 46 | end tell -- application 47 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Printmaster 2 | 3 | Printmaster is an attempt to automate my writing workflow. I'd like to go from Markdown-formatted plain text to a nicely set InDesign document, all with the press of a button. 4 | 5 | ## Here's the plan 6 | 7 | Since Markdown easily formats to HTML, I'm using InDesign's ability to import XML text and apply it to a previously designed InDesign template. 8 | 9 | 1. Given a Markdown document, 10 | 1. Convert it into XML 11 | 1. Pass that to an AppleScript file. The AppleScript copies a previously designed and formatted InDesign template, imports the XML into the template, and maps the template's styles to the tags. 12 | 1. The AppleScript exports this all as an InDesign document. 13 | 14 | # Requirements and Use 15 | 16 | I have CS4. If this works with any other version, let me know. 17 | 18 | Open up `Printmaster.scpt` in the AppleScript editor and change the paths. There are two: one for your template file (I've included a sample file) and another for your source. 19 | 20 | Run the applescript file and InDesign should open and create a new doc for you. Drag the XML from the sidebar over to the page, and your markdown text will propagate. This works best if you've set up your template's master pages in any sane way. 21 | 22 | ## Source File 23 | 24 | The source file needs to be XML in order for InDesign to work with it. For my example, I exported a markdown file to HTML and used only what was within the ``. I wrapped that within a `` tag and put an XML declaration on top. The goal is to eventually do all of that automatically. 25 | 26 | ## Unit types error 27 | 28 | If you are running Snow Leopard, you may see an error about the Adobe Unit Types scripting addition file: 29 | 30 | Error loading /Library/ScriptingAdditions/Adobe Unit Types.osax 31 | 32 | Apparently, the addition file installed with CS4 is 32-bit, while AppleScript expects 64-bit. There is an Adobe Knowledge Base [article](http://kb2.adobe.com/cps/516/cpsid_51615.html) on the topic witch lists a number of suggestions to work around the issue, including a 64-bit scripting addition file. 33 | 34 | # Help 35 | 36 | I'm always looking to automate this process further. If you have any interest on taking on the TODOs I've left, please let me know. 37 | 38 | # Resources 39 | 40 | You may be interested in reading up on Adobe's documentation on the topic. [This page](http://www.adobe.com/products/indesign/scripting/index.html) has a great variety of resources, including user guides and links to the [InDesign Scripting User Forum](http://forums.adobe.com/community/indesign/indesign_scripting). Who knew. 41 | 42 | # About 43 | 44 | Authored by [John Finley](mailto:jpfinley@gmail.com), September 2010. Released to the public domain. 45 | --------------------------------------------------------------------------------