• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
2

Not able to export .ai files. Illustrator just became inactive after click on upload

New Here ,
Feb 26, 2024 Feb 26, 2024

Copy link to clipboard

Copied

I am deveoping a plugin in which I need toupload selected document to my plugin. I am able to upload all type of file except .ai file. When I try to upload .ai file Illustrator became Inactive and I have to quit and reopen it to use. Can anyone suggest what should I do to upload .ai file. Please refer my code for reference:- 

 

 

function uploadAssets() {
var doc = app.activeDocument;
var placedItem = doc.selection[0];

if(placedItem === undefined){
   return JSON.stringify({imageData : null , imagePath : "no item selected"})
} else {
   var imageFile = new File(doc.fullName);
  // selected path name
  var selectedPath = imageFile.fsName
  // Converting file to binary data
  imageFile.open("r");
  imageFile.encoding = "Binary";
  var binaryData = imageFile.read();
  imageFile.close();
  return JSON.stringify({imageData : binaryData, imagePath : selectedPath})
 }
}

 

 and I am calling this function using evalScript

 

csInterface.evalScript(`uploadAssets()`, async (res) => {
      const resData = JSON.parse(res)

      if(resData.imageData !== null) {
        // Image binary data
        const binData = resData.imageData
  
        //Image file path
        const imgPath = resData.imagePath
      
        const splitModifiedPath = imgPath.split('/');
  
        // Name of the file
        const fileName = splitModifiedPath[splitModifiedPath.length - 1];
        const fileArray = fileName.split(".")
  
        // file extension
        const extension = fileArray[fileArray.length - 1]
  
  
        const buffer = new ArrayBuffer(binData.length);
        const view = new Uint8Array(buffer);
  
        for (let n = 0; n < binData.length; n++) {
          view[n] = binData.charCodeAt(n);
        }
        const type = `${extension}`;
        const blob = new Blob([buffer], { type });
        const fileUrl = new File([blob], fileName , {
          lastModified: new Date().getTime(),
          type,
        });
        setSelectedFrameName(fileUrl.name)
        handleSelectedFrame(fileUrl)
        
      } else {
        setSelectedFrameName(resData.imagePath)
        setNotSelected(true)
      }
    })

  };
  const handleTaskRadioFile = (e) => {
    setCheckFile(e.target.checked);
    setCheckFrame(false);
  };

 

Please help me in this. I will be greatful for your help
Thanks

TOPICS
Import and export , Scripting , Third party plugins

Views

57

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
no replies

Have something to add?

Join the conversation
Adobe