Not able to load DWg file properly using .Net

When I open a .dwg file using viewer the size of the image is very small and opened at the right corner

I am trying to open a file of size 9.5 mb.

I am attaching the imageAsposeConverted.png (13.0 KB)

@Sanuj,

I have observed your comments. Can you please share source file along with sample code and Aspose.CAD version you used on your end so that we may further investigate to help you out.

3384 V3.zip (5.0 MB)
Hi Adnan
I am using product version 18.8
I am attaching the file and sample code in the controller as well
We are using a mvc web solution.
The loading is very slow and image is very small and opened at the right corner

         using (Aspose.CAD.Image image1 = Aspose.CAD.Image.Load(file.InputStream))
                    {
                        Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions();
                        
                        ImageOptionsBase options = new Aspose.CAD.ImageOptions.PngOptions();
                        
                        options.VectorRasterizationOptions = rasterizationOptions;
                        
                        urlPath = System.IO.Path.Combine("~/Upload/" + Guid.NewGuid().ToString() + ".png");

                        
                        absolutePath = Request.MapPath(urlPath);
                        image1.Save(absolutePath, options);
                    }

Please unzip the attached file and get the .dwg file in it

@Sanuj,

Thank you for providing the source information. Can you please provide the generated PNG file for reference so that we may add ticket in our issue tracking system for resolution.

6a1e3129-7a51-4546-869b-bfe0684f8e25.zip (255.8 KB)
The file size after conversion is very huge as well.

@Sanuj,

I suggest you to please try using following sample code using latest Aspose.CAD for .NET 18.8 on your end. The generated Saved.png (8.0 KB) has also been attached.

    public static void TestDwgExport2()
    {
        try
        {
            String path = @"D:\Cad Data\";
            FileStream oMstream = new FileStream(path + "3384 V3.dwg", FileMode.Open, FileAccess.Read);
            int m_iPageCount = 0;
            oMstream.Position = 0;
            var m_oDocument = Aspose.CAD.Image.Load(oMstream);

            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;
            //resize fatto qui perchè lo fa nel costruttore
            if (((Aspose.CAD.FileFormats.Cad.CadImage)m_oDocument).Width > ((Aspose.CAD.FileFormats.Cad.CadImage)m_oDocument).Height)
            {
                if (((Aspose.CAD.FileFormats.Cad.CadImage)m_oDocument).Width > 1024)
                {
                    int iWidth = 1024;
                    int iHeight = (int)((1024.0f / (float)((Aspose.CAD.FileFormats.Cad.CadImage)m_oDocument).Width) * (float)((Aspose.CAD.FileFormats.Cad.CadImage)m_oDocument).Height);
                    rasterizationOptions.PageWidth = iWidth;
                    rasterizationOptions.PageHeight = iHeight;
                }
            }
            else
            {
                if (((Aspose.CAD.Image)m_oDocument).Height > 1024)
                {
                    int iHeight = 1024;
                    int iWidth = (int)((1024.0f / (float)((Aspose.CAD.FileFormats.Cad.CadImage)m_oDocument).Height) * (float)((Aspose.CAD.FileFormats.Cad.CadImage)m_oDocument).Width);
                    rasterizationOptions.PageWidth = iWidth;
                    rasterizationOptions.PageHeight = iHeight;
                }
            }

            ////
            int _iPageIndex = 0;
            int m_iResolution = 0;

            rasterizationOptions.BackgroundColor = Aspose.CAD.Color.White;
            rasterizationOptions.DrawColor = Aspose.CAD.Color.Black;
            rasterizationOptions.DrawType = Aspose.CAD.FileFormats.Cad.CadDrawTypeMode.UseDrawColor;
            rasterizationOptions.CenterDrawing = true;
            //layout impostato = al numero di pagina (un immagine per ogni layout)    
            // se non ci sono layout stampa tutti i livelli (una pagina)
            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[l++] = layout.LayoutName;
                    }
                }
                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(m_iResolution), Convert.ToDouble(m_iResolution));
            OptionsI.ResolutionSettings = oResI;
            OptionsI.VectorRasterizationOptions = rasterizationOptions;
            ((Aspose.CAD.Image)m_oDocument).Save(path + "Saved.png", OptionsI);
            
        }
        catch (Exception e)
        {
            String s = e.StackTrace;
        }
    }

Hi Adnan
I am not able to download the attached “saved.png” file
I am getting the following error
“# Oops! That page doesn’t exist or is private.”

@Sanuj,

I suggest you to please try downloading the attached files for your convenience.

3384 V3.zip (5.0 MB)

3384 V3 Rendered.zip (39.0 KB)