Groovy Scripting

Document | Masterspread | Spread | Story | Font | Paragraph Style | Character Style | Textframe | Rectangle
You can use Groovy Scripting to get access to your IDML files. Just install Groovy (Groovy Install Guide) and use some of the examples below.

Document
#!/usr/bin/env groovy -cp /mypath/idmllib-1.0.jar -Dcom.idmllib.license=MYSECRET-IDMLLIB-KEY

import de.fhcon.idmllib.api.elements.Idml

def idml = new Idml("/test-data/IDMLlib_DemoDocument.idml")
def document = idml.document
println document.CMYKProfile
println document.RGBProfile

Masterspread
#!/usr/bin/env groovy -cp /mypath/idmllib-1.0.jar -Dcom.idmllib.license=MYSECRET-IDMLLIB-KEY

import de.fhcon.idmllib.api.elements.Idml

def idml = new Idml("/test-data/IDMLlib_DemoDocument.idml")
def document = idml.document

document.masterSpreadIdList.each {masterSpreadId ->
  def masterSpread = document.getMasterSpreadById(masterSpreadId)
  println masterSpread.baseName
  println masterSpread.name
}

Spread
#!/usr/bin/env groovy -cp /mypath/idmllib-1.0.jar -Dcom.idmllib.license=MYSECRET-IDMLLIB-KEY

import de.fhcon.idmllib.api.elements.Idml

def idml = new Idml("/test-data/IDMLlib_DemoDocument.idml")
def document = idml.document

document.spreadIdList.each {spreadId ->
  def spread = document.getSpreadById(spreadId)
  println spread.pageCount
}

Story
#!/usr/bin/env groovy -cp /mypath/idmllib-1.0.jar -Dcom.idmllib.license=MYSECRET-IDMLLIB-KEY

import de.fhcon.idmllib.api.elements.Idml

def idml = new Idml("/test-data/IDMLlib_DemoDocument.idml")
def document = idml.document

document.storyIdList.each {storyId ->
  def story = document.getStoryById(storyId)
  println story.appliedNamedGrid
  println story.self
  println story.appliedTOCStyle
  println story.storyTitle
  println story.isTrackChanges()
}

Font
#!/usr/bin/env groovy -cp /mypath/idmllib-1.0.jar -Dcom.idmllib.license=MYSECRET-IDMLLIB-KEY

import de.fhcon.idmllib.api.elements.Idml

def idml = new Idml("/test-data/IDMLlib_DemoDocument.idml")
def document = idml.document

document.fonts.each {font ->
  font.fontFamilyList.each {fontFamily ->
    println fontFamily.name
  }
}

Paragraph Style
#!/usr/bin/env groovy -cp /mypath/idmllib-1.0.jar -Dcom.idmllib.license=MYSECRET-IDMLLIB-KEY

import de.fhcon.idmllib.api.elements.Idml

def idml = new Idml("/test-data/IDMLlib_DemoDocument.idml")
def document = idml.document

document.storyIdList.each {storyId ->
  def story = document.getStoryById(storyId)
  story.paragraphStyleRangeList.each {paragraphStyleRange ->
    println paragraphStyleRange.appliedParagraphStyle
    println paragraphStyleRange.hyphenationZone
    println paragraphStyleRange.ruleAboveLineWeight
    println paragraphStyleRange.ruleBelowLineWeight
  }
}

Character Style
#!/usr/bin/env groovy -cp /mypath/idmllib-1.0.jar -Dcom.idmllib.license=MYSECRET-IDMLLIB-KEY

import de.fhcon.idmllib.api.elements.Idml

def idml = new Idml("/test-data/IDMLlib_DemoDocument.idml")
def document = idml.document

document.storyIdList.each {storyId ->
  def story = document.getStoryById(storyId)
  story.paragraphStyleRangeList.each {paragraphStyleRange ->
    paragraphStyleRange.characterStyleRangeList.each {characterStyleRange ->
      println characterStyleRange.appliedCharacterStyle
      println characterStyleRange.fillColor
      println characterStyleRange.pointSize
      println characterStyleRange.strokeWeight
      println characterStyleRange.miterLimit
      println characterStyleRange.rubyFontSize
      println characterStyleRange.kentenFontSize
    }
  }
}

Textframe
#!/usr/bin/env groovy -cp /mypath/idmllib-1.0.jar -Dcom.idmllib.license=MYSECRET-IDMLLIB-KEY

import de.fhcon.idmllib.api.elements.Idml

def idml = new Idml("/test-data/IDMLlib_DemoDocument.idml")
def document = idml.document

document.spreadIdList.each {spreadId ->
  def spread = document.getSpreadById(spreadId)
  spread.textFrameList.each {textFrame ->
    println textFrame.self
    println textFrame.contentType
    println textFrame.isLocked()
  }
}


Rectangle
#!/usr/bin/env groovy -cp /mypath/idmllib-1.0.jar -Dcom.idmllib.license=MYSECRET-IDMLLIB-KEY

import de.fhcon.idmllib.api.elements.Idml

def idml = new Idml("/test-data/IDMLlib_DemoDocument.idml")
def document = idml.document

document.spreadIdList.each {spreadId ->
  def spread = document.getSpreadById(spreadId)
  spread.rectangleList.each {rectangle ->
    println rectangle.self
    println rectangle.contentType
    println rectangle.isLocked()
  }
}