Inkscape not creating output file. C#

Discussion about writing code for Inkscape.
evenflow58
Posts: 2
Joined: Fri Nov 07, 2014 6:33 am

Inkscape not creating output file. C#

Postby evenflow58 » Fri Nov 07, 2014 6:36 am

Can anybody tell me what I'm doing wrong here? The svg file is created but the output is not. I do not get any errors until I try and find the output file.

// Set the temporary file names.
string svgFileName = GetTempFileName() + ".svg";
string outputFile = GetTempFileName() + "." + fileType;

// Write the svg data to the temp file.
System.IO.File.WriteAllText(svgFileName, System.Web.HttpUtility.UrlDecode(svgData));

// Use inkscape to convert the svg data to the desired type.
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName = WebHelper.GetAppSettingAsString("InkscapeFilePath");
p.StartInfo.Arguments = String.Format("--file \"{0}\" --export-{1} \"{2}\" ", svgFileName, fileType, outputFile);
p.StartInfo.UseShellExecute = true;
p.Start();
p.WaitForExit();

User avatar
brynn
Posts: 10309
Joined: Wed Sep 26, 2007 4:34 pm
Location: western USA
Contact:

Re: Inkscape not creating output file. C#

Postby brynn » Sun Nov 09, 2014 11:36 pm

Are you talking about using the command line? I think that's a known issue. See this FAQ item: https://inkscape.org/en/learn/faq/#Open ... %20Windows

v1nce
Posts: 696
Joined: Wed Jan 13, 2010 4:36 am

Re: Inkscape not creating output file. C#

Postby v1nce » Mon Nov 10, 2014 4:00 am

Does WebHelper.GetAppSettingAsString("InkscapeFilePath") return what is expected ? (Path + exe name)
Maybe System.IO.File.WriteAllText returns before the file has been really written ? (So it is not found when you launch inkscape)
Maybe Arguments need to start with a " " ?

Launch your debugger to see what command is fired and make sure it works if you paste it into a dos box

evenflow58
Posts: 2
Joined: Fri Nov 07, 2014 6:33 am

Re: Inkscape not creating output file. C#

Postby evenflow58 » Tue Nov 11, 2014 12:39 am

As always it's the simplest things that get you. the string fileType was being passed in as all caps. Since I am using that variable as part of the command line call it needs to be sent as lower case. Only 6 hours of troubleshooting! Thanks for all your help.


Return to “Programming”