Hi,
Using Aspose.Diagram on linux platform to convert Visio VSD to PNG doesn’t work and throws the following exception:
Unhandled exception. System.TypeInitializationException: The type initializer for '↓♣' threw an exception.
---> System.TypeInitializationException: The type initializer for 'Gdip' threw an exception.
---> System.PlatformNotSupportedException: System.Drawing.Common is not supported on non-Windows platforms. See https://aka.ms/systemdrawingnonwindows for more information.
at System.Drawing.LibraryResolver.EnsureRegistered()
at System.Drawing.SafeNativeMethods.Gdip.PlatformInitialize()
at System.Drawing.SafeNativeMethods.Gdip..cctor()
--- End of inner exception stack trace ---
at System.Drawing.SafeNativeMethods.Gdip.GdipStringFormatGetGenericTypographic(IntPtr& format)
at System.Drawing.StringFormat.get_GenericTypographic()
at ↓♣..cctor()
--- End of inner exception stack trace ---
at ↓♣..ctor()
at ▬♣▬.☻(☻♣♣ ☻, ImageSaveOptions, Boolean ♣)
at ▬♣▬.☻(☻♣♣ ☻, ImageSaveOptions, Stream ♣, Boolean ♠)
at ▬♣▬.☻(☻♣♣ ☻, ImageSaveOptions, Stream ♣)
at ▬♣▬.☻(Stream ☻, ImageSaveOptions, Diagram ♣)
at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span`1 copyOfArgs, BindingFlags invokeAttr)
at d.♠(Object ☻)
at d(Object ☻)
at d(MethodBase ☻, Boolean)
at d.♠↑(d ☻, ♣)
at d.()
at d.(Boolean ☻)
at d.♠(Object ☻)
at d(Object ☻)
at d.♠()
at d.♠☻→(d ☻, ♣)
at d.()
at d.(Boolean ☻)
at d.♠(Object ☻)
at d(Object ☻)
at d.♠()
at d.☻(Object ☻, UInt32)
at d.(Boolean ☻)
at d.(Boolean ☻)
at d.☻(Object[] ☻, Type[], Type[] ♣, Object[] ♠)
at d.☻(Int32 ☻, Type[], Type[] ♣, Boolean ♠)
at d.♠→(d ☻, ♣)
at d.()
at d.(Boolean ☻)
at d.♠(Object ☻)
at d(Object ☻)
at d.♠()
at d.♠☻→(d ☻, ♣)
at d.()
at d.(Boolean ☻)
at d.♠(Object ☻)
at d(Object ☻)
at d.♠()
at d.☻(Object ☻, UInt32)
at d.(Boolean ☻)
at d.(Boolean ☻)
at d.☻(Object[] ☻, Type[], Type[] ♣, Object[] ♠)
at d.☻(Stream ☻, String, Object[] ♣, Type[] ♠, Type[] ♥, Object[] )
at d.☻(Stream ☻, String, Object[] ♣)
at d(Stream ☻, String, Object[] ♣)
at Aspose.Diagram.Diagram.Save(String filename, SaveOptions options)
at Program.<Main>$(String[] args) in /src/pg-aspose-linux/Program.cs:line 8
I could not find any mention of this limitation in the documentation.
I did see similar issues for Aspose.PDF and Aspose.Cells but the solutions mentioned there cannot be applied to Aspose.Diagram.
The use is pretty standard using the mcr.microsoft.com/dotnet/runtime:8.0
docker image with installed fonts.
I’m using the latest version (as of today) v24.2.0 of Aspose.Diagram nuget.
code:
using Aspose.Diagram;
using Aspose.Diagram.Saving;
var dir = args.Length > 0 ? args[0] : "/data";
var inPath = $"{dir}/in.vsd";
var outPath = $"{dir}/out.png";
var diagram = new Diagram(inPath);
diagram.Save(outPath, new ImageSaveOptions(SaveFileFormat.Png));
Please let me know if you need more details.