Free Support Forum - aspose.com

Image export failed: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index


#1

I got the following exception while converting a .DWG file to a PDF using Aspose.CAD:

Image export failed: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index

public MemoryStream ConvertCADToPDF(Stream cadStream, CompressionType? compressionType = null)
    {
        try
        {
            //Aspose.CAD.License lic = new Aspose.CAD.License();
            //lic.SetLicense(Serv.ImageProcessing.lic.generateLicenceStream());
            
            using (Aspose.CAD.Image image = Aspose.CAD.Image.Load(cadStream))
            {
                // Create an instance of CadRasterizationOptions
                Aspose.CAD.ImageOptions.CadRasterizationOptions rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions();
                // Set page width & height
                rasterizationOptions.PageWidth = 1200;
                rasterizationOptions.PageHeight = 1200;

                // Create an instance of PngOptions for the resultant image
                Aspose.CAD.ImageOptionsBase  options = new Aspose.CAD.ImageOptions.PdfOptions();
                // Set rasterization options
                options.VectorRasterizationOptions = rasterizationOptions;

                //saveDir = saveDir + "conic_pyramid_raster_image_out.pdf";
                // Save resultant image
                //image.Save(saveDir, options);
                MemoryStream memStream = new MemoryStream();
                image.Save(memStream, options);
                memStream.Seek(0, System.IO.SeekOrigin.Begin);
                if (compressionType != null)
                {
                    memStream = CompressPDFInMemory(memStream, compressionType);
                }
                return memStream;
            }
        }
        catch (Exception ex)
        {

            throw ex;
        }
    }

Attached sample CAD files throwing this exception.

CAD Files.zip (3.3 MB)


#2

@ibrahimamer,

I have worked with file shared by you using Aspose.CAD for .NET 18.8.1 and have been able to observe the issue. A ticket with ID CADNET-729 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.


#3

Thanks sir for your prompt response. We have a demo and we need this as soon as possible if possible


#4

@ibrahimamer,

We request for your patience and will share good news with you as soon as possible.


#5

@mudassir.fayyaz, @Adnan.Ahmad
Any updates?


#6

@ibrahimamer,

I have observed your comments. I regret to inform that issue is still unresolved. I like to inform that issue has been added recently in our issue tracking system and waiting for detailed investigation. We will share good news with you soon.


#7

@Adnan.Ahmad
Do you know how much time it would take?


#8

@ibrahimamer,

I have observed your comments and i like to inform that issue is still under investigation and we will be able to share ETA in few days. I request for your patience.


#9

@Adnan.Ahmad hello sir.

It been a long period. Do you have any updates?


#10

@ibrahimamer,

I have verified from our issue tracking system and regret to share that the issue is arising owing to missing features in API and its tentatively going to available and fixed during Q2 of 2019. We request for patience till the time the features are available and issue gets resolved.