Below Exception is being thrown while saving EMF file as PNG.
`{\"TargetSite\":\"Void Save(System.String, Aspose.Imaging.ImageOptionsBase, Aspose.Imaging.Rectangle)\",\"Message\":\"Image saving failed.\",\"Data\":[],\"InnerException\":{\"TargetSite\":\"Void Save(System.IO.Stream, Aspose.Imaging.ImageOptionsBase, Aspose.Imaging.Rectangle)\",\"Message\":\"Image export failed.\",\"Data\":[],\"InnerException\":{\"TargetSite\":\"#=zymnA5C9u8McCpSjGvBe9Tg0= #=zXn1$vX3xdjTT(System.String, System.Drawing.FontStyle, System.String)\",\"Message\":\"Required font 'Wingdings 2' style 'Regular' cannot be loaded. Cannot find any fonts installed on the system.\",\"Data\":[],\"InnerException\":null,\"HelpLink\":null,\"Source\":\"Aspose.Imaging\",\"HResult\":-2146233079,\"StackTrace\":\" at #=z$4TUXfqDyAyHEdRGTKyDl7YNfhMA.#=zXn1$vX3xdjTT(String #=zpj2_CXc=, FontStyle #=zf4rBbAs=, String #=zJcDD7dVEvO2g)\\n at #=z$4TUXfqDyAyHEdRGTKyDl7YNfhMA.#=zU_TgZQPx19DN(String #=zpj2_CXc=, Single #=z0QlsZU__UWCo, FontStyle #=zf4rBbAs=, String #=zJcDD7dVEvO2g)\\n at #=z$4TUXfqDyAyHEdRGTKyDl7YNfhMA.#=zU_TgZQPx19DN(String #=zpj2_CXc=, Single #=z0QlsZU__UWCo, FontStyle #=zf4rBbAs=)\\n at #=zCUUWM$YEIAxrxpD9h7g134Is3YJ7SfB4VdM9V8ts3d8N4sDIYzF3K4g=.#=zg6bQV14=(EmfLogFont #=z6zRyuwfzx8Ca)\\n at #=zPJifzdIh77kdxjzz1CXY9d4uPRhXYzEdZZShscw7CsmE7fb0H_N3J91kdu1Zgp2y2Q==.#=z110PQuvkYnbP()\\n at #=zPJifzdIh77kdxjzz1CXY9d4uPRhXYzEdZZShscw7CsmE7fb0H_N3J91kdu1Zgp2y2Q==.#=zwX3bdhU=(EmfText #=zanWLlDAx$Azm, EmfGraphicsMode #=ze09rFnsR6c6q, Single #=zyhAUDC5bi59e, Single #=ztmpTPcB9Dum8, Boolean #=znA4WKD8=)\\n at #=zPJifzdIh77kdxjzz1CXY9d4uPRhXYzEdZZShscw7CsmE7fb0H_N3J91kdu1Zgp2y2Q==.#=zwX3bdhU=(EmfText #=zanWLlDAx$Azm, EmfGraphicsMode #=ze09rFnsR6c6q, Single #=zyhAUDC5bi59e, Single #=ztmpTPcB9Dum8)\\n at #=z$0UzhsoEnOAawd3jR9e02z6ajjH3Ma3YlJ5SwaW55aIL.#=zvUNuDOE=(EmfRecord #=zBWXvCfVN8JvQ, Boolean #=zSEh_8HNf2iIe)\\n at #=zGfaFdsQ5i3QozdBv8pXqfdQUGaqdapJ37aNDusCYM8JNLF6zST29thifecxA.#=zepM9zCinn1DB(EmfImage #=zuWNc8uvFmIBK, StreamContainer #=zEqSgzci8Y1xw, EmfPlusMetafileDataType #=zG82M3Oo=, VectorRasterizationOptions #=zTq5iPJo=, Boolean #=zE$USDBFdg8oJSxw1gg==)\\n at #=zGfaFdsQ5i3QozdBv8pXqfdQUGaqdapJ37aNDusCYM8JNLF6zST29thifecxA.#=zvUNuDOE=(EmfImage #=zuWNc8uvFmIBK, StreamContainer #=zEqSgzci8Y1xw, EmfPlusMetafileDataType #=zG82M3Oo=, VectorRasterizationOptions #=zTq5iPJo=)\\n at #=zGfaFdsQ5i3QozdBv8pXqfdQUGaqdapJ37aNDusCYM8JNLF6zST29thifecxA.#=zvUNuDOE=(#=zH1$cGvfeH_ilekwIf_sgwXzGzs$T #=zBizdxSTv3gB1, EmfImage #=zuWNc8uvFmIBK, StreamContainer #=zEqSgzci8Y1xw, EmfPlusMetafileDataType #=zG82M3Oo=, VectorRasterizationOptions #=zTq5iPJo=)\\n at #=zGfaFdsQ5i3QozdBv8pXqfdQUGaqdapJ37aNDusCYM8JNLF6zST29thifecxA.#=zR$fxswY=(EmfRasterizationOptions #=zTq5iPJo=, Rectangle #=z5xxBuLbslXOtRNyTWw==)\\n at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)\\n at System.Reflection.MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)\\n at #=qd2g7ZNkUid4sQ0pL$pJ_ViXYwVEhDMSsRd3GNUooz9Q=.#=zo8ZLa0gJOc$Lb1e7h$J4OEAJHVkxHcIqd973YHc=(Object #=zwEa3Q4o=)\\n at #=qd2g7ZNkUid4sQ0pL$pJ_ViXYwVEhDMSsRd3GNUooz9Q=.#=zBPJSFJ5ThEtv$Pg1YMkDrCwN2bNI(Object #=zwEa3Q4o=)\\n at #=qd2g7ZNkUid4sQ0pL$pJ_ViXYwVEhDMSsRd3GNUooz9Q=.#=zSLsi9lIsIZ2DwA5alq3LPO5xK3kY(MethodBase #=zwEa3Q4o=, Boolean #=zpu3eV7A=)\\n at #=qd2g7ZNkUid4sQ0pL$pJ_ViXYwVEhDMSsRd3GNUooz9Q=.#=z5YE$pHHvXgIATItfgtesc4YMC6tb(#=qd2g7ZNkUid4sQ0pL$pJ_ViXYwVEhDMSsRd3GNUooz9Q= #=zwEa3Q4o=, #=qxSHhyecB4hTjHN06Yf$kV_aMcENeQpscYH6vyZApZzg= #=zpu3eV7A=)\\n at #=qd2g7ZNkUid4sQ0pL$pJ_ViXYwVEhDMSsRd3GNUooz9Q=.#=zhQZoLdXB9Iah$xq0Fk0KlGeD7oHzBaZ0DRk0dO2xbAEL()\\n at #=qd2g7ZNkUid4sQ0pL$pJ_ViXYwVEhDMSsRd3GNUooz9Q=.#=zTQmurJmXKXicotUyoii54V4=(Boolean #=zwEa3Q4o=)\\n at #=qd2g7ZNkUid4sQ0pL$pJ_ViXYwVEhDMSsRd3GNUooz9Q=.#=zo8ZLa0gJOc$Lb1e7h$J4OEAJHVkxHcIqd973YHc=(Object #=zwEa3Q4o=)\\n at #=qd2g7ZNkUid4sQ0pL$pJ_ViXYwVEhDMSsRd3GNUooz9Q=.#=zBPJSFJ5ThEtv$Pg1YMkDrCwN2bNI(Object #=zwEa3Q4o=)\\n at #=qd2g7ZNkUid4sQ0pL$pJ_ViXYwVEhDMSsRd3GNUooz9Q=.#=z011mjQCYnavjDRZbCwxcEzZX86isEYT5F07CES0=()\\n at #=qd2g7ZNkUid4sQ0pL$pJ_ViXYwVEhDMSsRd3GNUooz9Q=.#=zrMvWubW_30eANvC8ZunmoYQ=(Object #=zwEa3Q4o=, UInt32 #=zpu3eV7A=)\\n at #=qd2g7ZNkUid4sQ0pL$pJ_ViXYwVEhDMSsRd3GNUooz9Q=.#=zTQmurJmXKXicotUyoii54V4=(Boolean #=zwEa3Q4o=)\\n at #=qd2g7ZNkUid4sQ0pL$pJ_ViXYwVEhDMSsRd3GNUooz9Q=.#=zAHzd58mOJ11E8o_V5uWSX8sbiKbyvWH9GA==(Object[] #=zwEa3Q4o=, Type[] #=zpu3eV7A=, Type[] #=zGSGDA5E=, Object[] #=zIhqo6g0=)\\n at #=qd2g7ZNkUid4sQ0pL$pJ_ViXYwVEhDMSsRd3GNUooz9Q=.#=zADz6BgFN9piof4FdZpbooRLH5OToAqMC0Q==(Stream #=zwEa3Q4o=, String #=zpu3eV7A=, Object[] #=zGSGDA5E=, Type[] #=zIhqo6g0=, Type[] #=zQ3bb6LM=, Object[] #=zOWYB7Ts=)\\n at #=qd2g7ZNkUid4sQ0pL$pJ_ViXYwVEhDMSsRd3GNUooz9Q=.#=z8Lpo$JCqk5cQ9haQA40drOkRdgLPleLEppYJ1J4eGdZe(Stream #=zwEa3Q4o=, String #=zpu3eV7A=, Object[] #=zGSGDA5E=)\\n at #=zGfaFdsQ5i3QozdBv8pXqfdQUGaqdapJ37aNDusCYM8JNLF6zST29thifecxA.#=zcAaV63Q$mRTf(VectorRasterizationOptions #=zTq5iPJo=, Rectangle #=z5xxBuLbslXOtRNyTWw==)\\n at Aspose.Imaging.FileFormats.Emf.EmfImage.#=zmnmFPy_tLeUB(ImageOptionsBase #=zTq5iPJo=, #=z2HAnMiPBqgmytOMyBKbIHPq$f8$6RnQtDbyohm8yf92$1Cx$Lw== #=zj3Kg1u8=, Rectangle #=z5xxBuLbslXOtRNyTWw==)\\n at #=zn5JSUKdzcCdanppIHTdH6pvEUQRaVIKiKV4ib5lQhNojztzAAbBsKbxzvXfx_sgthQ==.#=znjnVT6WU9PepeOphoA==(VectorImage #=zkaM593LGWGOS, ImageOptionsBase #=zCo5scxeDl4fa, Rectangle #=z5xxBuLbslXOtRNyTWw==)\\n at #=zclE312p6wnhgrPzgzAVhZYi4LOQnL1a0KVPZp_RVQO_kN8gGtY2lW1dy6ZoA.#=znjnVT6WU9PepeOphoA==(ImageOptionsBase #=ztoO$rn4=, Rectangle #=z5xxBuLbslXOtRNyTWw==, VectorImage #=zkaM593LGWGOS)\\n at #=zclE312p6wnhgrPzgzAVhZYi4LOQnL1a0KVPZp_RVQO_kN8gGtY2lW1dy6ZoA.#=z$OhgNT8=(#=zw5B9X1Q= #=zfVATFpM=, Image #=zVDwg48E=, Stream #=zVSQ6wZg=, ImageOptionsBase #=ztoO$rn4=, Rectangle #=zdh1wQTJ75TVX, Rectangle #=z5xxBuLbslXOtRNyTWw==)\\n at #=zgjSC1cFxBmpPahcKFUTZomBqmqM_i9HitrI_CiKL_TL09BxY6g==.Export(Image #=zVDwg48E=, Stream #=zVSQ6wZg=, ImageOptionsBase #=ztoO$rn4=, Rectangle #=z5xxBuLbslXOtRNyTWw==)\\n at Aspose.Imaging.Image.Save(Stream stream, ImageOptionsBase optionsBase, Rectangle boundsRectangle)\",\"$type\":\"InvalidOperationException\"},\"HelpLink\":null,\"Source\":\"Aspose.Imaging\",\"HResult\":-2146233088,\"StackTrace\":\" at Aspose.Imaging.Image.Save(Stream stream, ImageOptionsBase optionsBase, Rectangle boundsRectangle)\\n at Aspose.Imaging.Image.Save(String filePath, ImageOptionsBase options, Rectangle boundsRectangle)\",\"$type\":\"ImageSaveException\"},\"HelpLink\":null,\"Source\":\"Aspose.Imaging\",\"HResult\":-2146233088,\"StackTrace\":\" at Aspose.Imaging.Image.Save(String filePath, ImageOptionsBase options, Rectangle boundsRectangle)\\n at Aspose.Imaging.Image.Save(String filePath, ImageOptionsBase options)\\n at ABC.Core.BLL.Excel.Artifact.ArtifactBLL.GeneratePictures(Worksheet workSheet) in /src/ABC.Core/BLL/Excel/Artifact/ArtifactBLL.cs:line 350\",\"$type\":\"ImageSaveException\"}`
and below is the sample code,
List<string> supportedImageTypes = new List<string> { ".png", ".bmp", ".gif", ".jpeg" };
foreach (var picture in workSheet.Pictures)
{
var imageName = GetImageName(picture.ImageType);
var imageFullPath = $"{Path.GetTempPath()}{imageName}";
try
{
if (imageFullPath.EndsWithIgnoreCase(supportedImageTypes))
{
Console.WriteLine($"Saved : {imageName} ");
}
else
{
File.WriteAllBytes(imageFullPath, picture.Data);
// load the EMF/Image file in an instance of Image
var image = Aspose.Imaging.Image.Load(imageFullPath);
// create an instance of PngOptions
var options = new Aspose.Imaging.ImageOptions.PngOptions();
// save EMF as a PNG
image.Save($"{imageFullPath}.png", options);
}
}
catch (Exception e)
{
Console.WriteLine("GeneratePictures failure - {@Exception}", e);
}
}