InDesign:访问文档字典 [英] InDesign: Accessing document dictionary
问题描述
在我的脚本中,我正在复制其中包含大量文本的单元格表。此文本具有一堆自定义连字符规则,这些规则保存在文档词典中,而不是用户词典中。通过打开用户词典并选择 Target 下的文档,可以在用户界面中对其进行访问。
将表复制到另一个文档时,不幸的是这些规则没有随其复制,并且文本也被更改。
如何访问此自定义文档字典,以便我的断字保留在目标文档中?
它可以使用 UserDictionary
访问用户词典,但是文档词典在哪里?
自从我终于找到要使用的适当类以来,我自己对此进行了回答:
可以使用 HyphenationExceptions
访问文档字典code>。为了从目标文档中获取所有自定义连字符,我执行了以下操作:
var myHyphenations = app.activeDocument.hyphenationExceptions;
for(var i = 0; i< myHyphenations.length; i ++){
if(myHyphenations [i] .name === Danish){
var mySourceDictionary = myHyphenations [一世];
mySourceHyphenations = mySourceDictionary.addedExceptions;
休息
}
}
出于某种原因,
换句话说,下面的代码不起作用(实际上给了我一本挪威语词典): / p>
var mySourceDictionary = app.activeDocument.hyphenationExceptions.item(丹麦);
由于这个原因,我不得不循环数组直到找到所需的数组为止:( Danish 。
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?
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").
这篇关于InDesign:访问文档字典的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!