CADImage.SaveToFile(,EMF,) Exception
Moderators: SDS, support, admin
CADImage.SaveToFile(,EMF,) Exception
Hi
I have un exception when a try to write a EMF file.
The exception is : "A generic error occurred in GDI+."
I have a trial licence. I'm testing the library.
Please, Can you help me ?
Thank you
I have un exception when a try to write a EMF file.
The exception is : "A generic error occurred in GDI+."
I have a trial licence. I'm testing the library.
Please, Can you help me ?
Thank you
Code: Select all
...
if (cadImage != null)
{
if (cadImage.CurrentLayout == null)
return;
DRect rect = Rectangle(cadImage.CurrentLayout.Entities);
cadImage.SaveToFile("D:Travail\\GDTM\\test.emf", ImageFormat.Emf, rect);
}
...
private static DRect Rectangle(CADEntityCollection entities)
{
double maxX = double.MinValue, maxY = double.MinValue;
double minX = double.MaxValue, minY = double.MaxValue;
int count = entities.Count;
foreach (CADEntity entity in entities)
{
if (entity.EntType == EntityType.Line)
{
DRect box = entity.Box;
maxY = System.Math.Max(maxY, System.Math.Max(box.top, box.bottom));
minY = System.Math.Min(minY, System.Math.Min(box.top, box.bottom));
maxX = System.Math.Max(maxX, System.Math.Max(box.right, box.left));
minX = System.Math.Min(minX, System.Math.Min(box.right, box.left));
}
}
DRect rect = new DRect(minX, minY, maxX, maxY);
return rect;
}
Re: CADImage.SaveToFile(,EMF,) Exception
Hello,
This error may be caused by permissions, then there are two possible scenarios:
1) The account that the application is running as doesn't have permission to write to the target directory. Add write permissions for this account on the target directory.
2) The target directory does not exist. Create it first or check if the directory path is correct.
There is a syntax error in the directory path:
Should be:
So try the scenario described in the p. 2. If it doesn't solve the problem, check the sizes of the DRect which is returned by the Rectangle() method.
The stack trace for this error could give us more information about the issue. Please, post it here.
Mikhail
This error may be caused by permissions, then there are two possible scenarios:
1) The account that the application is running as doesn't have permission to write to the target directory. Add write permissions for this account on the target directory.
2) The target directory does not exist. Create it first or check if the directory path is correct.
There is a syntax error in the directory path:
Code: Select all
cadImage.SaveToFile("D:Travail\\GDTM\\test.emf", ImageFormat.Emf, rect);
Code: Select all
cadImage.SaveToFile("D:\\Travail\\GDTM\\test.emf", ImageFormat.Emf, rect);
The stack trace for this error could give us more information about the issue. Please, post it here.
Mikhail
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support