是否可以在 text/word 上方插入锚定文本框?

Is it possible to Insert an anchored text frame above a text/word?

我想通过在每个 text/word 上方放置一个锚定文本框来标记文档中的每个 CharacterStyle。我对在 indesign 中编写脚本还很陌生,所以非常感谢任何帮助。

这是预期的输出:

我找到了解决方案,对于那些可能遇到与我相同问题的人,这是我的代码:

    app.findChangeGrepOptions.includeFootnotes = false; 
    app.findChangeGrepOptions.includeHiddenLayers = false; 
    app.findChangeGrepOptions.includeLockedLayersForFind = false; 
    app.findChangeGrepOptions.includeLockedStoriesForFind = false; 
    app.findChangeGrepOptions.includeMasterPages = false; 
    app.findGrepPreferences = NothingEnum.nothing; 
    app.findGrepPreferences.appliedCharacterStyle = style; 
    app.findGrepPreferences.findWhat = ".+"; 

    var found_item = doc.findGrep();
    var res_count = found_item.length;

    if(res_count > 0){
            var found_text = found_item[0].paragraphs.firstItem();
            var insertion_character =  (found_text.characters.lastItem().index);
            var check_insertion_character = insertion_character + 1;
            var alt_insertion_character = (found_text.characters.firstItem().index);
            var the_story = found_text.parentStory;
            try{

            app.selection = the_story.insertionPoints[check_insertion_character];
            app.selection = the_story.insertionPoints[alt_insertion_character];
            }catch(err){
               alert(err);
            }

            var the_anchored_frame = app.selection[0].textFrames.add({geometricBounds:["0","0",1,10],anchoredObjectSettings:{anchoredPosition: AnchorPosition.ABOVE_LINE, horizontalReferencePoint: AnchoredRelativeTo.ANCHOR_LOCATION, verticalReferencePoint: VerticallyRelativeTo.TOP_OF_LEADING}}); 

            the_anchored_frame.contents = style;

           // the_anchored_frame.appliedObjectStyle = real_anchor_style; 
        }

干杯