InDesign文本修改脚本跳过段落

时间:2018-03-16 12:34:18

标签: javascript adobe-indesign

以下InDesign(Java)脚本不会更改所有段落的文本内容和格式: -

for (var j = 0; j < app.activeDocument.stories.length; j++) {    
    for (var k = 0; k < app.activeDocument.stories.item(j).paragraphs.length; k++) {
        var myText = app.activeDocument.stories.item(j).paragraphs.item(k);
        myText.contents = C2Unic(myText.contents, myText.appliedFont.fontFamily);
        myText.appliedFont = app.fonts.item("Mangal");
        myText.pointSize = myText.pointSize*0.878;
        myText.composer="Adobe World-Ready Paragraph Composer";
    }
}

在下图中注意粉红色背景的内容。所有这些都有源格式。发生了什么事?

enter image description here

1 个答案:

答案 0 :(得分:2)

这可能不是解决方案,但有时在修改contents时有助于循环翻阅段落。

for (var j = 0; j < app.activeDocument.stories.length; j++) {    
    for (var k = app.activeDocument.stories.item(j).paragraphs.length; k--; ) {
        var myText = app.activeDocument.stories.item(j).paragraphs.item(k);
        myText.contents = C2Unic(myText.contents, myText.appliedFont.fontFamily);
        myText.appliedFont = app.fonts.item("Mangal");
        myText.pointSize = myText.pointSize*0.878;
        myText.composer="Adobe World-Ready Paragraph Composer";
    }
}