gpt4 book ai didi

javascript - 如何在 InDesign 中设置 (textFrame) pageItem 以在页面中手动更改后更新母版页的位置/大小?

转载 作者:行者123 更新时间:2023-11-28 09:13:09 32 4
gpt4 key购买 nike

我有一个执行以下操作的脚本:

    var document = app.documents.item(0);
var layer = document.layers.itemByName("Normal");
var allTextFrames = toArray(layer.textFrames);
var moved = selectWhere("moved", "label", allTextFrames)[0];
var notMoved = selectWhere("notMoved", "label", allTextFrames)[0];
var instance = selectWhere("instance", "label", allTextFrames)[0];
$.writeln("Moved : " + moved.geometricBounds.join(", "));
$.writeln("Moved overr: " + moved.overriddenMasterPageItem.geometricBounds.join(", "));
$.writeln("notMoved : " + notMoved.geometricBounds.join(", "));
$.writeln("notMoved overr: " + notMoved.overriddenMasterPageItem.geometricBounds.join(", "));



var overr = moved.overriddenMasterPageItem;
moved.geometricBounds = [moved.overriddenMasterPageItem.geometricBounds[0]
,moved.overriddenMasterPageItem.geometricBounds[1]
,moved.overriddenMasterPageItem.geometricBounds[2]
,moved.overriddenMasterPageItem.geometricBounds[3]];
moved.visibleBounds = [moved.overriddenMasterPageItem.visibleBounds[0]
,moved.overriddenMasterPageItem.visibleBounds[1]
,moved.overriddenMasterPageItem.visibleBounds[2]
,moved.overriddenMasterPageItem.visibleBounds[3]];

但是,如果我更改母版页中的文本框架,它不会更新“移动的”文本框架...

例如,pageItem 有一个属性,当设置为“-1”时,它将使用母版页值。我一直在寻找类似的东西,但位置和大小。

fillTint number 只读 PageItem 填充颜色中使用的色调百分比。 (要指定色调百分比,请使用 0 到 100 范围内的数字;要使用继承或覆盖的值,请使用 -1。)来源:http://jongware.mit.edu/iccs5_html_3.0.3d/iccs5/pc_PageItem.html

最佳答案

我不会标记为答案,因为有时不起作用;

这是删除文本框并恢复的脚本。然后它向其提供旧文本框架的数据。它还会将文本框架链接到上一个和下一个文本框架。

使用方法:

  • 创建脚本并粘贴以下内容
  • 选择移动的文本框并运行脚本。
  • 完成!!!

    #target "indesign"
    #targetengine "mySessionX"
    var SCRIPT_NAME = "Restore moved text frames";
    try{
    app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, SCRIPT_NAME);
    }catch(e){
    alert(e);
    }

    function main(){
    removeOverrides(app.selection[0]);
    }

    function removeOverrides(textFrame){
    if(textFrame.constructor.name != "TextFrame"){
    throw new Error("No text frame selected");
    }
    // save data
    var contents = textFrame.contents;
    var contentType = textFrame.contentType;
    var nextTextFrame = textFrame.nextTextFrame;
    var previousTextFrame = textFrame.previousTextFrame;
    var masterPageTextFrame = textFrame.overriddenMasterPageItem;
    var page = textFrame.parentPage;
    if(nextTextFrame){
    nextTextFrame.previousTextFrame = null;
    }
    if(previousTextFrame){
    previousTextFrame.nextTextFrame = null;
    }

    // remove overrides
    textFrame.removeOverride();

    // restore state
    var newTextFrame = masterPageTextFrame.override(page);
    newTextFrame.contents = contents;
    newTextFrame.contentType = contentType;

    // update right and left
    if(nextTextFrame){
    nextTextFrame.previousTextFrame = newTextFrame
    }
    if(previousTextFrame){
    previousTextFrame.nextTextFrame = newTextFrame
    }


    newTextFrame.recompose();
    alert("Restored");
    }

关于javascript - 如何在 InDesign 中设置 (textFrame) pageItem 以在页面中手动更改后更新母版页的位置/大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16040966/

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