We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Exception at Diagram.save when converting to image

Hello,
This is the file and code.

sample02.zip (372.1 KB)


    private PageListResult ConvertVisioToImage()
    {
        try
        {
            var pageResultList = new List<PageResult>();

            Aspose.Diagram.License license = new Aspose.Diagram.License();
            license.SetLicense("Aspose.Total.lic");

            var pageImgDir = CreateTempDirectory();

            // Convert .vsd and .vsdx file to PDF.
            var diagram = new Aspose.Diagram.Diagram(this._stream);

            var options = new Aspose.Diagram.Saving.ImageSaveOptions(Aspose.Diagram.SaveFileFormat.PNG);
            options.Resolution = 96;

            //Change conversion area
            options.SameAsPdfConversionArea = true;

            options.SmoothingMode = Aspose.Diagram.Saving.SmoothingMode.AntiAlias;

            for (int i = 1; (i <= diagram.Pages.Count) && (i <= this.config.DocumentMaxPageNumber); i++)
            {
                if (diagram.Pages[i - 1].Background == Aspose.Diagram.BOOL.True)
                    continue;
                foreach (Aspose.Diagram.Layer layer in diagram.Pages[i].PageSheet.Layers)
                {
                    if (layer.Visible.Value == Aspose.Diagram.BOOL.True)
                    {
                        layer.Print.Value = Aspose.Diagram.BOOL.True;
                    }
                }

                using (MemoryStream imgStream = new MemoryStream())
                {
                    options.PageIndex = i - 1;
                    diagram.Save(imgStream, options);
                    imgStream.Position = 0;
                }
            }

            return new PageListResult(pageResultList, this.config.DocumentMaxPageNumber < diagram.Pages.Count);
        }
        catch (Exception ex)
        {
            throw new Exception("Failure converting visio", ex);
        }
    }

@PFU.DSOL2,
We managed to replicate an overflow error in our environment. It has been logged under the ticket ID DIAGRAMNET-51368 in our bug tracking system. We have linked your post to this ticket and will keep you informed regarding any available update.

@PFU.DSOL2,

The linked ticket ID DIAGRAMNET-51368 has been fixed. Please download and try the new version 17.10 of Aspose.Diagram for .NET API.