Hello,
I’m using Aspose.CAD (.NET) to covert a DXF file to JPG (output image size 1000 x 1000).
I want that the rasterized drawing to scale to fit the 1000 x 1000 area while keeping its ratio and
with many DXF file this operation works as expected however with a few DXF files the output drawing only fill around 1/4 of the space.
I verified this unexpected behaviour with both version 20.7.0 and 20.9.1 of Aspose.CAD.
Can you give me some feedback?
Here the code I use and an attachment with a DXF file that gives issues:
using (Aspose.CAD.FileFormats.Cad.CadImage cadImage = (Aspose.CAD.FileFormats.Cad.CadImage)Aspose.CAD.Image.Load(filename))
{
Aspose.CAD.Rectangle rect = cadImage.Bounds;
var options = new Aspose.CAD.ImageOptions.JpegOptions();
Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions()
{
BackgroundColor = Aspose.CAD.Color.White,
PageHeight = 1000,
PageWidth = 1000,
DrawType = Aspose.CAD.FileFormats.Cad.CadDrawTypeMode.UseObjectColor
};
options.VectorRasterizationOptions = rasterizationOptions;
// save DXF as a JPEG
cadImage.Save(Path.GetDirectoryName(filename) + "\\" + Path.GetFileNameWithoutExtension(filename) + ".jpg", options);
}
0700410_01_B-1.dxf.zip (108.8 KB)
Hello,
try adding Layout to rasterizationoptions
In java i do it as below
CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions();
rasterizationOptions.setUnitType(UnitType.Millimeter);
rasterizationOptions.setBackgroundColor(Color.getWhite());
rasterizationOptions.setPageWidth(420);
rasterizationOptions.setPageHeight(297);
// rasterizationOptions.setExportAllLayoutContent(true);
rasterizationOptions.setLayouts(new String[] { “Model” });
Thanks for your reply.
I tried with yours rasterization options but the problem persisted (I repeat so not to be misunderstood that this issue happen only with a few DXF files like the one I attached):
Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new CadRasterizationOptions()
{
BackgroundColor = Aspose.CAD.Color.White,
PageHeight = 1000,
PageWidth = 1000,
UnitType = UnitType.Millimeter,
Layouts = new string[] { “Model” }
};
@kymossrl
Please provide the output file that you are getting in your end along with desired output that you want to achieve so that we may judge the difference and try helping you further.
Here a compressed file with two output images.
The one with the name that start with “Scaled wrongly” has the drawing rasterized within 1/4 of the actual image area (1000 x 1000), the file with the name that start with “Scaled correctly” you can see how the drawing fit the the image area as expected.
The output JPG with the name that start with “Scaled wrongly” is the result of the input DXF that I’ve attached in the first post.
Output JPG.zip (78.2 KB)
@kymossrl
I have opened a ticket with ID CADNET-1218 in our issue tracking system to further investigate the scaling related issue on our end. This thread has been linked with the issue so that you may be notified once the issue will be fixed.
Any news about this issue?
@kymossrl
The issue has been marked for resolution in upcoming version and we request for your patience. You will also need to call UpdateSize() for an attached sample as it has incorrect dimensions.
The issues you have found earlier (filed as CADNET-1218) have been fixed in this update.