从剪贴板粘贴到InDesign时获取奇怪的字符

时间:2015-03-26 07:06:03

标签: xml adobe-indesign

我有一个脚本,它获取剪贴板的内容并将它们写入文件,以便我可以将内容粘贴到InDesign中。它工作得比较早,但现在它用这些字符替换所有引号,“,Äù”。我将粘贴之前和之后:

之前:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<?aid style="50" type="snippet" readerVersion="6.0" featureSet="257" product="8.0(370)" ?>
<?aid SnippetType="PageItem"?>
<Document LinkedSpreads="" DOMVersion="8.0" Self="d">
</Document>

之后:

<?xml version=”1.0” encoding=”UTF-8” standalone=”yes”?>
<?aid style=”50” type=”snippet” readerVersion=”6.0” featureSet=”257” product=”8.0(370)” ?>
<?aid SnippetType=”PageItem”?>
<Document LinkedSpreads=”” DOMVersion=”8.0” Self=”d”>
</Document>

我通常可以判断我的代码是否会改变,但我想我可能在InDesign中改变了一些东西?我要回过头来看看是不是我做了什么,但平时有人见过这个?

如果我将代码粘贴到.idms文件中,然后放置文档,它将继续工作。这是有问题的脚本。

1 个答案:

答案 0 :(得分:0)

我不确定它是什么,但我没有将文件编码设置为“UTF-8”,它现在似乎正在运行。这是我正在使用的代码片段:

doc.textPreferences.typographersQuotes = false;
var tf = doc.textFrames.add();
var story = tf.parentStory;
//story.appliedLanguage = app.languagesWithVendors[0];
story.insertionPoints[0].select();
app.paste();
var str = story.contents;
if (str.indexOf("‚Äú")!=-1 || str.indexOf("Äù")!=-1) {
    alert("Weird quotes found. Try saving to an .idms file and then placing it.");
    //str = str.replace("”", '"');
    //alert(str.substr(0,200));
 }

tf.remove();
var f = File(Folder.temp + "/temp_snippet.idms");
//f.encoding = "UTF-8"; // commented out here
f.open('w');

但是我已经再次注释了该行,它仍在工作。捣蛋鬼。

更新:它停止了工作。然后它又开始工作了。然后停了下来所有这些都没有修改导入代码。如果我首先将其保存到IDMS文本文件而不是将其复制到剪贴板,它将继续工作。

以下是完整的脚本http://pastebin.com/F5Re4C2R