Copy link to clipboard
Copied
I have a PSD file, containing layers, that I want to open in Illustrator.
To open PSD files, the Illustrator Scripting Guide suggests using the following construct
--------------------------------------------------------------------------------------------
// Opens a Photoshop file containing layers with
// preferences set to preserve layers
var psdOptions = preferences.photoshopFileOptions;
psdOptions.preserveLayers = true;
psdOptions.pixelAspectRatioCorrection = false;
// open a file using these prefs
var fileRef = File(psdFilePath);
if (fileRef != null) {
var docRef = open(fileRef, DocumentColorSpace.RGB);
}
------------------------------------------------------------------------------------------------------
and the Application.open() method is described as follows app.open(file[, documentColorSpace][, options])
i am trying to open psd files, not using a variable "fileRef".
--------------------------------------------------------------------------------------------------------
var fileRef = File(psdFilePath);
if (fileRef != null) {
var docRef = open(fileRef, DocumentColorSpace.RGB);
}
----------------------------------------------------------------------------------------------
In both cases, using or not using "var psdOptions", when opening a PSD file, the application shows a window "Photoshop Import Option".
Moreover, when using the notation
--------------------------------------------------------------------
var docRef = app.open(fileRef, DocumentColorSpace.RGB, psdOptions);
--------------------------------------------------------------------
Where I explicitly specify the options for opening a document, I get the following response:
Exception has occurred: 9007
unknown open options found.
Is this a bug, or am I not understanding something?
Use the first way. Add this before the open() function:
app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;
Copy link to clipboard
Copied
Use the first way. Add this before the open() function:
app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;
Copy link to clipboard
Copied
Yes, this method works... But it also works without var psdOptions declaration...
Copy link to clipboard
Copied
yea, if you're gonna disable the part of the script that tells you when something's wrong, you've gotta do your own checks to make sure everything goes right. Otherwise it's gonna go wrong and you're not gonna know till later.
Just add some validation logic before the app.open() call to ensure that all the arguments you're passing in are valid.