InDesign: Accessing document dictionary

不羁的心 提交于 2019-12-13 05:25:58

问题


In my script, I am copying a table of cells that have a lot of text in them. This text has a bunch of custom hyphenation rules that are saved in the document dictionary, NOT in the user dictionary. This is accessed in the UI by opening User dictionary and selecting the document under Target.

When copying the table to another document, these rules are unfortunately not copied with it, and the text is changed.

How can I access this custom document dictionary so that my hyphenations are retained in the target document?

It is possible to access the user dictionary with UserDictionary, but where is the document dictionary located?


回答1:


Answering this myself since I finally found the proper class to use:

The document dictionary can be accessed using HyphenationExceptions. To get all custom hyphenations from my target document, I did the following:

var myHyphenations = app.activeDocument.hyphenationExceptions;
for (var i = 0; i < myHyphenations.length; i++) {
    if (myHyphenations[i].name === "Danish") {
        var mySourceDictionary = myHyphenations[i];
        mySourceHyphenations = mySourceDictionary.addedExceptions;
        break
        }
    }

For some reason, it seems that it is NOT possible to get a certain HyphenationException using its name.

In other words, the below code does not work (it actually gives me a Norwegian dictionary):

var mySourceDictionary = app.activeDocument.hyphenationExceptions.item("Danish");

For this reason, I had to loop the array until I found the one I needed: ("Danish").



来源:https://stackoverflow.com/questions/21972372/indesign-accessing-document-dictionary

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!