Copy link to clipboard
Copied
Hi All,
I'm trying to pass the filepath as argument from the javascript to python script. Is it possible to pass the arugment from the indesign script to python code? Any help is much appreciated.
Thanks
Copy link to clipboard
Copied
There's probably a better way but I'd probably just save the string to a tmp file and read that tmp file in the Python.
Copy link to clipboard
Copied
Thanks brian! how to save the string in the tmp file?
Copy link to clipboard
Copied
var myFileStr = "C:/My/File/Path";
var f = File(Folder.temp + "/tempFileName.txt");
f.encoding = "UTF-8";
f.open("w");
f.write(myFileStr);
f.close();
Copy link to clipboard
Copied
In addition to what @brian_p_dts mentioned, I would like to ask a followup question, how are you connecting InDesign and Python? If you share what you are currently doing we could find a cleaner way perhaps. For one I could think that Python could access InDesign API via COM(Python should have a library for doing so), if so then you could take much of your code totally in Python and JS vanishes from the equation or you could use a mix of Python COM interface with app.doScript. If MAC comes into picture something similiar could be worked out there too with Applescript and Python. However, as said if you share what you have done/achieved till now then we can brainstorm on the options, else what Brain has said is the simplest and surest way to make it work
-Manan
Copy link to clipboard
Copied
Thanks Manan! My existing Script was developed in JS. Now I developed the new python script functionlity for deleting the elements in HTML file using xpath. My requirement is to pass the HTML file path from JS UI to Python script.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more