處理大量文本排版時,常需將單一文本框拆分為多個獨立段落框。手動拆分極其繁瑣,一段 JS 腳本即可一鍵完成。
/////////////////////////////////////////////////////////////////
//divide textframe v.2 -- cs,cs2
//>=--------------------------------------
// divides a multiline text field into separate textframe objects.
// basically, each line in the selected text object
// becomes it's own textframe. vertical spacing of each new line is based on leading.
//
// this is the opposite of my "join textframes" scripts which
// takes multiple lines and stitchs them back together into the same object.
//>=--------------------------------------
// js code (c) copyright: john wundes ( john@wundes.com ) www.wundes.com
//copyright full text here: https://www.wundes.com/js4ai/copyright.txt
/////////////////////////////////////////////////////////////////
if(app.documents.length > 0){
var sel = app.activeDocument.selection;
if(sel.length == 1 && sel[0].typename == "TextFrame"){
var tf = sel[0];
if(tf.contents.indexOf("\n") != -1){
var lines = tf.contents.split("\n");
var top = tf.top;
var left = tf.left;
var leading = tf.paragraphs[0].leading;
if(typeof leading == "string") leading = parseFloat(leading);
tf.remove();
for(var i=0; i

腳本作者 John Wundes (john@wundes.com),請尊重版權保留註釋。更多實用腳本見 wundes.com/js4ai。
善用腳本自動化重複勞動,將精力留給真正的設計決策。