Hi,
We are getting below exception when trying to convert dwf to png file.
Exception thrown: ‘Aspose.CAD.CadExceptions.ImageLoadException’ in Aspose.CAD.dll
Here is the program I am using
using Aspose.CAD;
using Aspose.CAD.FileFormats.Dwf;
using Aspose.CAD.ImageOptions;
using System;
using System.IO;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(“Hello World!”);
string imgFileName = null;
int pageCount = 0;
try
{
using (Aspose.CAD.Image image = Aspose.CAD.Image.Load("dwftest.dwf"))
{
ImageOptionsBase imgOption = new PngOptions();
pageCount = 1;
FileStream fileStream = null;
DwfImage dwfImage = (DwfImage)image;
foreach (var page in dwfImage.Pages)
{
imgFileName = "TestDwf" + "_" + pageCount + ".png";
Console.WriteLine("Convert>>page>>"+page);
fileStream = new FileStream(imgFileName, FileMode.Create);
using (MemoryStream imageStream = new MemoryStream())
{
CadRasterizationOptions options = new CadRasterizationOptions
{
Layouts = new string[] { page.Name }
};
options.PageHeight = image.Height * 300;
options.PageWidth = image.Width * 300;
imgOption.VectorRasterizationOptions = options;
image.Save(imageStream, imgOption);
Console.WriteLine("Convert>>result file>>" + imgFileName);
imageStream.WriteTo(fileStream);
// Close stream
fileStream.Close();
imageStream.Close();
}
pageCount++;
}
}
}
catch (Exception e)
{
}
}
}
}
Attached is the dwftest.dwf file we are using.dwftest.zip (58.8 KB)
Thanks®ards,
Gangadhar