Copy link to clipboard
Copied
I have a ASP .NET c# website and I want to call a JavaScript file (with extension .jsx) to create a new image file from Photoshop to display.
No issues or problems with the JavaScript file.
The problem is finding the code in c# to call the JavaScript file from .NET C# (version 4.6) with the correct parameters.
Hoping somebody has solved this before can answer.
Stephen
Finally found a working Solution for .NET C# to use .JavaScript .JSX files.
Add Reference from COM object for Photoshop
Add to top of Code page;
using Photoshop;
Code required is;
string cFile = HttpContext.Current.Server.MapPath("~/Test Action.jsx");
Photoshop.ApplicationClass app = new Photoshop.ApplicationClass();
string[] aArguments= new string[0]; // as no Parameters
app.DoJavaScriptFile(cFile,aArguments,1) ; // not sure why it is 1 as final paramet
...Copy link to clipboard
Copied
If your JSX file has
#target Photoshop
on first line in script, then doubleclick on this file can run script in Photoshop (by default).
Doubleclick could be replaced with runing JSX filem from command line. No arguments required.
Copy link to clipboard
Copied
Thanks for your reply.
But the code is embedded in a website and the user does not have access to the Desktop, so your proposed solution cannot work
The code required is linked to the action of a button click and is in .NET C# and it requires to execute the JavaScript .Jsx file.
Stephen.
Copy link to clipboard
Copied
If PS and JSX are both server-side then it should work.
You could run "c:\your\path\action.jsx" from C# .NET
Copy link to clipboard
Copied
Yes thanks, both files/applications are server side.
But I'm looking for the .NET C# syntax of executing the action.JSX file as it does not operate as a usual JavaScript file
as .JSX is Extended version.
Stephen
Copy link to clipboard
Copied
I mean like this: .net - Run an exe from C# code - Stack Overflow But you will run jsx instead exe.
If you have properly set #target in jsx.
JSX has nothing todo with <script></script> in HTML. (except panels inside Photoshop)
Copy link to clipboard
Copied
Thanks for link to Stack Flow .Net C# code
However this code (adjusted for actual file names ) creates error as follows;
Win 32 Exception was Caught
The specified executable is not a valid application for this OS platform.
So cannot in .NET C# treat .Jsx as Script or Exe - so how can I execute the JavaScript .Jsx file?
Stephen
Copy link to clipboard
Copied
Finally found a working Solution for .NET C# to use .JavaScript .JSX files.
Add Reference from COM object for Photoshop
Add to top of Code page;
using Photoshop;
Code required is;
string cFile = HttpContext.Current.Server.MapPath("~/Test Action.jsx");
Photoshop.ApplicationClass app = new Photoshop.ApplicationClass();
string[] aArguments= new string[0]; // as no Parameters
app.DoJavaScriptFile(cFile,aArguments,1) ; // not sure why it is 1 as final parameter could not find documentation on options.
app.Quit();
Thanks for contributions.
Hope this solution helps, somebody else.
Stephen