Free Support Forum - aspose.com

Exception"Image export failed" when converting DXF file into PDF (C#)

Hello, we are having problem tryng to convert a CAD file into images

This is the exception thrown:

— Aspose.CAD.CadExceptions.ImageSaveException: Image export failed. —> System.IO.FileLoadException: Could not load file or assembly ‘Aspose.Pdf, Version=17.6.1.0, Culture=neutral, PublicKeyToken=716fcc553a201e56’ or one of its dependencies. The located assembly’s manifest definition does not match the assembly reference.

and this is our code:
Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions();
rasterizationOptions.PageWidth = ((Aspose.CAD.Image)m_oDocument).Width;
rasterizationOptions.PageHeight = ((Aspose.CAD.Image)m_oDocument).Height;
rasterizationOptions.BackgroundColor = Aspose.CAD.Color.White;
rasterizationOptions.DrawColor = Aspose.CAD.Color.Black;
rasterizationOptions.DrawType = Aspose.CAD.FileFormats.Cad.CadDrawTypeMode.UseDrawColor;
rasterizationOptions.CenterDrawing = true;
if (((Aspose.CAD.FileFormats.Cad.CadImage)m_oDocument).Layouts.Count > 0)
{
Aspose.CAD.FileFormats.Cad.CadLayoutDictionary layouts = ((Aspose.CAD.FileFormats.Cad.CadImage)m_oDocument).Layouts;
string[] layoutNames = new string[1];
int l = 0;
foreach (Aspose.CAD.FileFormats.Cad.CadObjects.CadLayout layout in layouts.Values)
{
if (l == _iPageIndex)
{
layoutNames[0] = layout.LayoutName;
}
l++;
}
rasterizationOptions.Layouts = layoutNames;
}
Aspose.CAD.ImageOptions.PngOptions OptionsI = new Aspose.CAD.ImageOptions.PngOptions();
OptionsI.ColorType = Aspose.CAD.FileFormats.Png.PngColorType.TruecolorWithAlpha;
//OptionsI.TransparentColor = new Aspose.Imaging.TransparentColorSetting(Aspose.Imaging.Color.Transparent);
Aspose.CAD.ResolutionSetting oResI = new Aspose.CAD.ResolutionSetting(Convert.ToDouble(120), Convert.ToDouble(120));
OptionsI.ResolutionSettings = oResI;
OptionsI.VectorRasterizationOptions = rasterizationOptions;
((Aspose.CAD.Image)m_oDocument).Save(_oOutputStream, OptionsI);

and here’s a sample file Office.zip (39.6 KB)

thanks a lot

@BooleServer,

I have observed your comments. Can you please share environment details so that we may further investigate to help you out. Also you mentioned about Aspose.Pdf version in your details. Can you please confirm which Aspose version you are using on your end to achieve your requirements.

windows server 2012 or windows 7, every Aspose libs up to date (aspose.cad and aspose.pdf are 17.12 version).

@BooleServer,

I have worked with file shared by you using Aspose.CAD for .NET 17.12 and have been able to observe the issue. A ticket with ID CADNET-500 has been created in our issue tracking system to further investigate and resolve the issue. This thread has been linked with issue so that you may be automatically notified once issue will be fixed.

Please share us some news about CADNET-500

@BooleServer,

I have observed your comments. I like to share that this issue is going to be resolved tentatively in Aspose.CAD 18.1. We will share good news with you soon.

The issues you have found earlier (filed as CADNET-500) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by mudassir.fayyaz

Tried with aspose.cad 18.3.0 but the issue remain the same!
Aspose.CAD.CadExceptions.ImageSaveException: Image export failed. —> System.IO.FileLoadException: Could not load file or assembly ‘Aspose.Pdf, Version=18.1.0.0, Culture=neutral, PublicKeyToken=716fcc553a201e56’ or one of its dependencies. The located assembly’s manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
at .Export(Image , Stream , ImageOptionsBase , Rectangle )

Please try it!

Why aspose cad needs to call aspose.pdf? And why search for a precise version of this?

Please solve it as soon as possible: our customers cannot convert any of their cad files.
Share news with us, please: thi is a blocking issue for us now!

@BooleServer,

I have observed your comments and like to share that Aspose.PDF is not required internally by Aspose.CAD API in all cases. It calls Aspose.PDF internally only in special cases like, when one have link to PDF in DWG drawing for example. In that case then one can specify location to his/her PDF dll and Aspose.CAD dll shall use it. As requested earlier, please provide a working sample project along with source file that is causing issue on your end so that we may investigate it further to help you.

You have already our code, a sample file and the exeption that throws: you can find them in the very first post of this thread (December 2017!!!).
THAT sample file with THAT piece of code DID WORK with aspose libraries prior of version 17.12, and stop working with 17.12: you affirmed

[quote=“mudassir.fayyaz, post:7, topic:168822”]
The issues you have found earlier (filed as CADNET-500) have been fixed in this update
[/quote] referring to version 18.1 BUT the problem still happens wit 18.3

I repeat: our code and the sample file DID NOT changed during time: the only things changed are aspose.cad libraries, so for us the CADNET-500 issue is still open.
Let us know if you can replicate the problem, as you replicated with 17.12 version.
At this time this is an extremely urgent issue.

@BooleServer,

I have tested your sample code using Aspose.CAD for .NET 18.3 on my end using office.dwg file shared by you. I have observed the ImageSave exception message but there is no pointing to Aspose.PDF for this now. I have tested the same code with other files and it works. We are further checking your file and sample code using latest API version and will share feedback with you ASAP.

Tha issue happens with every files we tried from this sample page:

@BooleServer,

I have created this sample project based on sample code provided by you and there seems to be no exception while using AutoCAD 2011 Sample Files on my end. Can you please try using this on your end.

Hello, We tried this simple project: initialli it didn’t work with the same error, then after a rebuild it goes ok.
In our actual project even if rebuilded it throws the same exeption.
We’ll try with some other tats, it seems to be related on project complexity the fact aspose.cad search for aspose.pdf?

@BooleServer,

It is good to hear that my sample project worked on your end. You may please observe your project on your end and share with us if there is still an issue. You may also compare your sample project with one I have shared as well.

The issues you have found earlier (filed as ) have been fixed in this update.