gpt4 book ai didi

javascript - InDesign 文本修改脚本跳过段落

转载 作者:行者123 更新时间:2023-11-30 14:43:25 24 4
gpt4 key购买 nike

以下 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

最佳答案

这可能不是解决方案,但有时在您修改 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";
}
}

关于javascript - InDesign 文本修改脚本跳过段落,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49320918/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com