Skip to content

Instantly share code, notes, and snippets.

@ccgus
Created August 30, 2013 18:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ccgus/6392658 to your computer and use it in GitHub Desktop.
Save ccgus/6392658 to your computer and use it in GitHub Desktop.
var list = """George Washington
John Adams
Thomas Jefferson
James Madison
James Monroe
John Quincy Adams
Andrew Jackson
Martin Van Buren
William Henry Harrison
John Tyler
James Knox Polk
Zachary Taylor
Millard Fillmore
Franklin Pierce""";
var acorn = JSTalk.application("Acorn");
var doc = acorn.open("/Path/To/Template.acorn");
var lines = list.split(/\r?\n/);
for (idx in lines) {
var name = lines[idx];
// the second layer must be a shape layer for this to work.
var shapeLayer = doc.layers()[1]
// and we have to already have a text box as the single element on the layer
var textShape = shapeLayer.graphics()[0]
var html = "<span style='font-size: 25pt; color: white; font-weight: bold;'>" + name + "</span>"
textShape.setHTMLString(html)
// save it to where you want as a PNG
doc.dataOfType("public.png").writeToFile("/tmp/template-" + name + ".png");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment