Skip to main content
Participant
August 1, 2022
Question

Read the opened file in Illustartor

  • August 1, 2022
  • 1 reply
  • 796 views

Hi Team,
I am trying to read the image from the illustrator and open them in my application.
Currently, I am not able to get the file of the image as it is reading from my local system.

Eg: file:///C:/Users/KeerthanaMaruthachal/Pictures/okta.png

Consider I am getting above path from Illustrator.

1.Where I am not able to read the file and convert them to a file object.

2. Even I am trying to use the node.js functionality for reading the file . I need to use the js file inside my jsx file 

Tried below ways 

$._ext.evalFile(File('..\Client\CEPMPMUtil.js'));
or 
$.evalFile(File('..\Client\CEPMPMUtil.js'));

Still no luck facing below error:
Error 21: undefined is not an object. Line: 1 -> $._ext_ILST.getCurDocumentPath()
Error 21: undefined is not an object. Line: 1 -> $._ext_ILST.createFileObjWithFilePath('documentPath')

Any help team here?


 

This topic has been closed for replies.

1 reply

Charu Rajput
Community Expert
Community Expert
August 2, 2022

Hi,

Not sure I understand you quetsion completely. If you are looking the answers for the following issues

1. Open local image from your system in your Illustartor application

The following code assumes, Test.png file exists inside the Desktop folder. Change path corresponding to your machine.

var _file = new File('~/Desktop/Test.png');
if(_file.exists){
    app.open(_file);
}

 

2. If you want to open the image file from the web

For this case, first you need to download the image using node methods and after that you can open the file as above and us ethe path where images is downloaded.

 

3. To include js file

Before evalFile() like below, you can check whether the file exists or not. It may be possible the path that you are using is not the correct path.

$.evalFile(File('~/Desktop/sample.js'));

So try like

var _file = new File('~/Desktop/sample.js');
if (_file.exists) {
    $.evalFile(_file);
} else {
    alert('File not exists');
}

 

Also, it depends on the structure of your js file, how you write the methods in that file and how are you calling them. It will be easy for us to help if you share your code for the file, that you want to include or eval.

Best regards
Participant
August 2, 2022

I have attached the js file and jsx file as well.

Structure will be something like

com.mpm.extension
          Client -> CEPMPUTIL.js
          Host ->main.jsx

 

Let me know if any more info required or can we connect over a call also if needed.
Thanks

Charu Rajput
Community Expert
Community Expert
August 2, 2022

Hello,

I see you are uisng the CEP panel, so in this case main.jsx can't be host. Instead your all jsx files must be evaluated by your js file. Below is the link to the samples where you can see how files interact with each other in CEP panel.

https://github.com/Adobe-CEP/Samples

 

Below is also incorrect

$._ext.evalFile(File('~\Client\CEPMPMUtil.js'));
 
$.evalFile(File('~\Client\CEPMPMUtil.js'));

But this is not the correct flow that you are doing. Have a look on the above samples.

Best regards