【问题标题】:How to convert an SVG file to WMF format?如何将 SVG 文件转换为 WMF 格式?
【发布时间】:2015-10-23 06:48:36
【问题描述】:

我想将 .svg 矢量图形转换为 .wmf。我查看了这个库http://wmf.codeplex.com/,但没有成功。

我找到了这个库http://svg2swf.sourceforge.net/,但是我不知道如何在c#项目中使用它。

编辑:inkscape 的这种用法也不适合我(无法打开 wmf 文件)。

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));
}

【问题讨论】:

  • 你说的没有成功是什么意思?你遇到了什么问题?
  • 我链接的这个库是用于 wmf 操作,而不是转换。我可能是错的,因为文档很差,所以将其包含在内只是为了保存。

标签: c# svg file-conversion wmf


【解决方案1】:

使用 Inkscape 的 0.91 版,您可以在命令行中使用特定选项来执行此操作:

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);
}

输入文件:https://upload.wikimedia.org/wikipedia/commons/f/fd/Ghostscript_Tiger.svg

文档:inkscape --help

【讨论】:

  • 将在星期一尝试,肯定会回到这里提供反馈。
  • 基本上你用-f打开一个文件等等,我展示的语法是专门用于批处理的:D
  • 很好的 Inkscape。
猜你喜欢
  • 2011-10-25
  • 2012-04-10
  • 2010-12-18
  • 2013-06-26
  • 2012-12-15
  • 1970-01-01
  • 2021-11-06
  • 1970-01-01
  • 2013-10-29
相关资源
最近更新 更多