I'm brand new to writing scripts. I need to have a script in Photoshop that opens an Illustrator (.ai) file. Normally when you do that manually, Photoshop brings up a dialog box called "Import PDF". Once the user selects the file to open, I need the script to set 3 of the parameters in that dialog box.
It looks like I need to use this command but I'm not positive:
Code: Select all open(File(openDialog()));
That works fine. But it sets those parameters to their default values.
I think I need to set the parameters this way:
Code: Select allvar OpenAIFile = new PDFOpenOptions
OpenAIFile.antiAlias = false
OpenAIFile.mode = OpenDocumentMode.CMYK
OpenAIFile.resolution = 300
But how do I insert these parameters into the Open command? There must be a simple way to do this.
I'm having a hard time trying to figure out Adobe's scripting documentation. I appreciate any help.
Looking for help with "Open()" command
-
txuku
Looking for help with "Open()" command
Bonjour
Anything like that :
Code: Select all//PDFOpenOptions.jsx
var OpenAIFile = new PDFOpenOptions;
OpenAIFile.antiAlias = false;
OpenAIFile.mode = OpenDocumentMode.CMYK;
OpenAIFile.resolution = 300;
var myFolder = Folder.selectDialog("select folder");
if(myFolder != null)
{
var fileList = myFolder.getFiles(/\.(pdf)$/i);
for(var i = 0 ;i < fileList.length; i++)
{
if(fileList instanceof File)
{
var doc= open(fileList,OpenAIFile);
}
}
};
Anything like that :
Code: Select all//PDFOpenOptions.jsx
var OpenAIFile = new PDFOpenOptions;
OpenAIFile.antiAlias = false;
OpenAIFile.mode = OpenDocumentMode.CMYK;
OpenAIFile.resolution = 300;
var myFolder = Folder.selectDialog("select folder");
if(myFolder != null)
{
var fileList = myFolder.getFiles(/\.(pdf)$/i);
for(var i = 0 ;i < fileList.length; i++)
{
if(fileList instanceof File)
{
var doc= open(fileList,OpenAIFile);
}
}
};
-
sak1364
Looking for help with "Open()" command
Merci beaucoup.
I pasted the code into ExtendScript, but the For loop doesn't execute.
I am trying to understand just what your script does. (As I said I'm very new at writing Java Script.) I understand the the user is asked to select a folder. But does the user ever actually select the file? Or is the script choosing a file from the folder? The second won't work for me. I need to have the user select his/her file and let the script set the open/import parameters so that it can continue to manipulate the file.
I pasted the code into ExtendScript, but the For loop doesn't execute.
I am trying to understand just what your script does. (As I said I'm very new at writing Java Script.) I understand the the user is asked to select a folder. But does the user ever actually select the file? Or is the script choosing a file from the folder? The second won't work for me. I need to have the user select his/her file and let the script set the open/import parameters so that it can continue to manipulate the file.
-
txuku
Looking for help with "Open()" command
Forgive me!
file .ai did not be file .pdf
This is better :
Code: Select all//PDFOpenOptions.jsx
var OpenAIFile = new PDFOpenOptions;
OpenAIFile.antiAlias = false;
OpenAIFile.mode = OpenDocumentMode.CMYK;
OpenAIFile.resolution = 300;
var myFolder = Folder.selectDialog("select folder");
if(myFolder != null)
{
var fileList = myFolder.getFiles(/\.(ai)$/i); // (pdf)$/i);
for(var i = 0 ;i < fileList.length; i++)
{
if(fileList instanceof File)
{
var doc= open(fileList,OpenAIFile);
}
}
};
file .ai did not be file .pdf
This is better :
Code: Select all//PDFOpenOptions.jsx
var OpenAIFile = new PDFOpenOptions;
OpenAIFile.antiAlias = false;
OpenAIFile.mode = OpenDocumentMode.CMYK;
OpenAIFile.resolution = 300;
var myFolder = Folder.selectDialog("select folder");
if(myFolder != null)
{
var fileList = myFolder.getFiles(/\.(ai)$/i); // (pdf)$/i);
for(var i = 0 ;i < fileList.length; i++)
{
if(fileList instanceof File)
{
var doc= open(fileList,OpenAIFile);
}
}
};
-
sak1364
Looking for help with "Open()" command
txuku, thank you so much for your help. Your solution isn't quite what I needed, because I want the user to specify 1 file. But, I was able to use your solution to figure out how to do it. I knew there had to be a simple solution:
Code: Select all var OpenAIFile = new PDFOpenOptions;
OpenAIFile.antiAlias = false;
OpenAIFile.mode = OpenDocumentMode.CMYK;
OpenAIFile.resolution = 300;
var SelectedFilePath = File.openDialog("Select the file"); // Prompt user to select the .ai file
var CurrentFile = open(SelectedFilePath, OpenAIFile); // Open the .ai file and set parameters
Thank you again for your time & help!
Code: Select all var OpenAIFile = new PDFOpenOptions;
OpenAIFile.antiAlias = false;
OpenAIFile.mode = OpenDocumentMode.CMYK;
OpenAIFile.resolution = 300;
var SelectedFilePath = File.openDialog("Select the file"); // Prompt user to select the .ai file
var CurrentFile = open(SelectedFilePath, OpenAIFile); // Open the .ai file and set parameters
Thank you again for your time & help!
-
txuku
Looking for help with "Open()" command
Excuse me
This is a careless mistake on my part ........
you can also specify the type of file line 6:
Code: Select allvar SelectedFilePath = File.openDialog("Select the file ai","ai:*.ai" );