Skip to content

Convert SVG to WMF on Linux/mono. #538

Open
@mustelan

Description

@mustelan

Description

Some time ago I found code snippet (using this library) convert SVG to WMF:

using (var memoryStream = new MemoryStream())
using (var image = new Bitmap(100,100))
using (var bufferGraphics = Graphics.FromImage(image))
using (var metafile = new Metafile(memoryStream, bufferGraphics.GetHdc()))
{
    using (var graphics = Graphics.FromImage(metafile))
    {
        svgDocument.Draw(graphics);
    }
    return (memoryStream.ToArray(), metafile.Width, metafile.Height);
}

I'm not exactly sure how this code works, but works and produces correct WMF :)

Now, I migrate from Windows environment to Linux/MONO and when I use version 2.4.3 I get an exception:

System.TypeInitializationException : The type initializer for 'Svg.SvgDocument' threw an exception.
  ----> System.EntryPointNotFoundException : GetDC

I understand in this case version 2.4.3 is strictly related with Windows GDI library and it's not possible to work with mono.

But when I use prerelease version (3.0.20-g594db9696a) there is no exception, but produced WMF is empty (0 bytes length).
There is any possibility to produce correct WMF file on mono with this library?

Example

sample_svg.txt

Used Versions

  • version 2.4.3
  • 3.0.20-g594db9696a

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions