Message Boards Message Boards

0
|
3198 Views
|
3 Replies
|
2 Total Likes
View groups...
Share
Share this post:

Calling an application Inkscape with RunProcess?

Posted 3 years ago

I am trying to emulate the command presented in this Stack Exchange question, about

...implement a way in Mathematica to export graphics to PDF and then use Inkscape from within Mathematica to post process the resulting output with the pdf-latex export option in Inkscape.

The code snippet is as follows:

Module[{fig, str = NotebookDirectory[]}, 
 fig = Plot[Cos[2 x], {x, 0, 2 Pi}, 
   AxesLabel -> {"$x$", "$\\cos{2x}$"}];
 Export[str <> "in.pdf", fig];
 RunProcess[{"inkscape", "-z", "-D", "--file=" <> str <> "in.pdf", 
   "--export-pdf=" <> str <> "out.pdf", "--export-latex"}, 
  ProcessEnvironment -> 
   Association[
    DeleteCases[GetEnvironment[All], "LD_LIBRARY_PATH" -> _]]];]

But I get the following error when executing the command:

RunProcess: Program inkscape not found.  Check Environment["PATH"].

I tried also "/Applications/Inkscape.app/" as the path argument to RunProcess but the same error is printed.

I am running Mac OS 10.14.6, with Inkscape 1.0.0.

Can anyone indicate me with a correct path? Or am I missing something else about Inkscape here?

POSTED BY: Ehud Behar
3 Replies
Posted 3 years ago

Last time I used Inkscape was a few years ago on Ubuntu. Just installed the MacOS version. Command line interface from terminal

/Applications/Inkscape.app/Contents/MacOS/inkscape --help

So, add /Applications/Inkscape.app/Contents/MacOS to the WL PATH as described in my earlier post and it should work.

POSTED BY: Rohit Namjoshi
Posted 3 years ago

Hmm.. Command not found.

But inkscape is installed on my computer!

Any idea? Sorry for being too novice.

POSTED BY: Ehud Behar
Posted 3 years ago

Hi Ehud,

Open the Terminal app and type

which inkscape
inkscape -V

If that works you need to make sure that the path returned by which is in the Mathematica PATH.

SetEnvironment["PATH" -> Environment["PATH"] <> ":" <> "path returned by which"]
POSTED BY: Rohit Namjoshi
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract