使用 ExtendScript 在 Adob​​e Illustrator 中打开 PSD 文件

Opening PSD file in Adobe Illustrator using ExtendScript

我正在尝试编写脚本以在 Adob​​e Illustrator 中打开 PSD 文件并进行一些批处理。问题是我无法提供所需的打开选项。

来自docs

Application

  • open(File file, DocumentColorSpace documentColorSpace, Anything options)

    Opens the specified document file.

...

OpenOptionsPhotoshop

Options for opening a Photoshop document, used with the open method.

所以,我假设我可以将 OpenOptionsPhotoshopopen 方法一起使用,但是如何呢?

我试过这样做:

var psdFile = new File('file.psd');

var options = new OpenOptionsPhotoshop();
options.preserveHiddenLayers = true;

app.open(psdFile, DocumentColorSpace.RGB, options);

但是它说:

OpenOptionsPhotoshop does not have a constructor.

知道如何将选项传递给 open 方法吗?

您不应该创建 OpenOptionsPhotoshop 对象,您需要以某种方式访问​​它。您可以这样访问它:

app.preferences.photoshopFileOptions.preserveHiddenLayers = true;

我在这里找到了这个:

https://yearbook.github.io/esdocs/#/Illustrator/Preferences/photoshopFileOptions https://yearbook.github.io/esdocs/#/Illustrator/Application/preferences

快编辑,open方法的文档也在这里。第二个和第三个参数是可选的。

https://yearbook.github.io/esdocs/#/Illustrator/Application/open