Skip to main content
Known Participant
January 14, 2022
Question

Passing file path from JS to python

  • January 14, 2022
  • 2 replies
  • 636 views

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

 

 

This topic has been closed for replies.

2 replies

Community Expert
January 15, 2022

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

-Manan
Rocky@Author
Known Participant
January 15, 2022

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.

brian_p_dts
Community Expert
Community Expert
January 14, 2022

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. 

Rocky@Author
Known Participant
January 14, 2022

Thanks brian! how to save the string in the tmp file?