1

I would like to convert .svg vector graphic to .wmf. I looked into this library http://wmf.codeplex.com/, but with no success.

I have found this library http://svg2swf.sourceforge.net/, but I do not know how to use it in c# project.

Edit: Also this usage of inkscape not works for me (wmf file could not be opened).

public static string Result = @"Polygon-6666.wmf";
public static string Source = @"Polygon-6.svg";

public void CreatePng(string filename)
{
    var inkscapeArgs = string.Format(@"-f ""{0}"" -e ""{1}""", Source, Result);

    var inkscape = Process.Start(new ProcessStartInfo("inkscape.exe", inkscapeArgs));
}
aybe
  • 15,516
  • 9
  • 57
  • 105
Piotr M
  • 499
  • 3
  • 9
  • 27

1 Answers1

3

Using the version 0.91 of Inkscape, you have specific options in the command-line to do that:

private void Demo()
{
    var inkscapePath = @"C:\Program Files\Inkscape\inkscape.exe";
    var inputPath = @"D:\Downloads\Ghostscript_Tiger.svg";
    var outputPath = @"D:\Downloads\Ghostscript_Tiger.wmf";
    Svg2Wmf(inkscapePath, inputPath, outputPath);
}

private void Svg2Wmf(string inkscapePath, string inputPath, string outputPath)
{
    if (inkscapePath == null) throw new ArgumentNullException("inkscapePath");
    if (inputPath == null) throw new ArgumentNullException("inputPath");
    if (outputPath == null) throw new ArgumentNullException("outputPath");
    var arguments = string.Format("--export-wmf=\"{0}\" \"{1}\"", outputPath.Trim('"'), inputPath.Trim('"'));
    Process.Start(inkscapePath, arguments);
}

Input file: https://upload.wikimedia.org/wikipedia/commons/f/fd/Ghostscript_Tiger.svg

Documentation: inkscape --help

aybe
  • 15,516
  • 9
  • 57
  • 105