c# - 如何将 SVG 文件转换为 WMF 格式?

标签 c# svg file-conversion wmf

我想将 .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));
}

最佳答案

使用 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

关于c# - 如何将 SVG 文件转换为 WMF 格式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31748727/

相关文章:

python - 使用 Python 和 LibreOffice 将 pdf 转换为 docx 以及将 doc 转换为 docx 时遇到问题

c# - Steamkit2 给特定用户的消息

html - SVG/D3 - 嵌入 svg 图像的 g 未显示(g 的大小为 0 x 0,而 svg 图像无处可见)

c# - 为接口(interface)重载 operator==

image-processing - 如何将 SVG 图像 "paths"转换为单独的 PNG 图像?

css - 向网站添加多种 Icomoon 字体

batch-file - 我需要脚本来处理所有 dav 文件

video - 亚马逊弹性转码器与 FFMPEG

c# - 如何使用azure函数或逻辑应用程序监视sftp中的多个位置?

c# - 可重复使用的动画