Saving a visio document as a TIFF Format

I have found an interesting error. I am converting a vsd/vsdx file to a tiff and if i gave the resolution 264 or higher number then I got an exception which is


"A generic error occurred in GDI+."


" at System.Drawing.Image.Save(Stream stream, ImageCodecInfo encoder, EncoderParameters encoderParams)\r\n at \u000f .\u0002(Image \u0002, Stream \u0003, \b \u0005, Boolean \b)\r\n at \b .\u0003(Stream \u0002, ImageSaveOptions \u0003, Diagram \u0005)\r\n at \b .\u0002(Stream \u0002, ImageSaveOptions \u0003, Diagram \u0005)\r\n at Aspose.Diagram.Diagram.Save(Stream stream, SaveOptions options)\r\n at Aspose.Diagram.Diagram.Save(String filename, SaveOptions options)\r\n at .Converter.Business.AsposeSdk.AsposeDiagramDoc.CreateThumbnail(ThumbnailModel thumbnail)"


I tried to save the vsd file to vsdx and then converting to TIFF but I got the same error.

I’ve attached the file here.


and my code

public override ThumbnailResult CreateThumbnail(ThumbnailModel thumbnail)
{
      <span style="color:blue;">var</span> result = <span style="color:blue;">new</span> <span style="color:#2b91af;">ThumbnailResult</span>();
      <span style="color:blue;">try</span>
      {
          var diagram = <span style="color: blue;">new</span> <span style="color: rgb(43, 145, 175);">Diagram</span>("test.vsd");<br> 
          <span style="color:#2b91af;">ImageSaveOptions</span> options = <span style="color:blue;">new</span> <span style="color:#2b91af;">ImageSaveOptions</span>(<span style="color:#2b91af;">SaveFileFormat</span>.TIFF);
          options.JpegQuality = 100;
          options.Resolution = 264; //it works with 263 or lower 
          <span style="color:blue;">if</span> (thumbnail.AllPages)
          {
              options.PageIndex = 0;
              options.PageCount = diagram.Pages.Count;
          }
          <span style="color:blue;">else</span>
          {
              options.PageIndex = thumbnail.StartPage;
              options.PageCount = thumbnail.EndPage - thumbnail.StartPage;
          }


          options.TiffCompression = thumbnail.IsColored ? <span style="color:#2b91af;">TiffCompression</span>.Lzw : <span style="color:#2b91af;">TiffCompression</span>.Ccitt4;
          <span style="color:blue;">var</span> visioTiff = <span style="color:blue;">new</span> <span style="color:#2b91af;">MemoryStream</span>();

          diagram.Save(<span style="color:maroon;">@"C:\temp2\TEST_TIFF.tiff"</span>,options);   </pre><pre style="font-family: Consolas; font-size: 13px; background: white;"><pre style="font-family: Consolas; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial;"><span style="color:green;">              //diagram.Save(visioTiff, options);</span>


result.Thumbnail = visioTiff.ToArray();
result.Message = “Successful”;
result.Result = Result.Successful;
      }
      <span style="color:blue;">catch</span> (<span style="color:#2b91af;">Exception</span> ex)
      {
          result.Result = <span style="color:#2b91af;">Result</span>.Error;
          result.Message = ex.Message; 
      } 

      <span style="color:blue;">return</span> result;
  }</pre></div>

Hi Ertan,


Thank you for contacting support. We’ve tested your source Visio against the latest version 16.12.0 of Aspose.Diagram for .NET API. We could not replicate the said error on our side. Please download and use the latest version and let us know how that goes on your side. If you can reproduce this error using the latest version 16.12.0, then please prepare a simple console application which reproduces this error on your side and attach its ZIP archive to your reply post. It’ll help us to replicate the error on our side.

Oh its my mistake. I was using version of 16.11 and now i’ve used 16.12 and it works. I am new to here and before i ask a question, firstly i will use the newest version and try it.


Thank you for your support.

Hi Ertan,


Thank you for the details. We recommend our clients use the latest Aspose API version because it incorporates a lot new features, enhancements and bug fixes. Furthermore, if you come across any issue using the latest Aspose API version, then please proactively post complete details of the use case in this forum. We’ll help you appropriately.