Ramesh Gujarathi

Not able to generate image at Server side (C#)

Recommended Posts

Hi Team,

We are experiencing a issue, which was working fine till last month.

The issue is:

We send the Chart SVG information generated from Javascript to server side to save the image as png.  The code part of saving the image is not working properly.  The created image is always blank. No exceptions are thrown.

The Assemblies info:

  • FusionCharts - 1.2.2.0
  • SharpVectors.Converters 1.0.0.0
  • SharpVectors.Rendering.Wpf 1.0.0.0
  • SharpVectors.Runtime 1.0.0.0
  • SharpVectors.Core 0.3.1.41457 

Please help us on this.

*  *  *  *  *

Here is the pice of the code:

private static MemoryStream GetJSImage(string svgHtml, string fileFormat)
{
          string type = fileFormat.ToString().ToLower(System.Globalization.CultureInfo.CurrentCulture);
          byte[] svg = Encoding.ASCII.GetBytes(svgHtml);
          WpfDrawingSettings ds = new WpfDrawingSettings();
           using (StreamSvgConverter ssc = new StreamSvgConverter(ds))
           {
                  ssc.SaveXaml = false;
                  ssc.SaveZaml = false;
 
                  ImageEncoderType encoder = ImageEncoderType.JpegBitmap;
                 switch (type)
                 {
                         case "png":
                                 encoder = ImageEncoderType.PngBitmap;
                                 break;
                        case "jpeg":
                                 encoder = ImageEncoderType.JpegBitmap;
                                 break;
                  }
                  ssc.EncoderType = encoder;
                  ssc.SaveXaml = false;
                 using (MemoryStream svgStream = new MemoryStream(svg))
                 {
                        TextReader svgData = new StreamReader(svgStream);
                        using (MemoryStream exportObjectStream = new MemoryStream())
                       {
                                 ssc.Convert(svgData, exportObjectStream);
                                return exportObjectStream;
                       }
                }
        }
}
Edited by Ramesh Gujarathi

Share this post


Link to post
Share on other sites

Hi Ramesh,

Would like to request you please check your implementation.

Please note FusionCharts supported ASP.NET private export server is working properly at our end.

Please implement FusionCharts supported ASP.NET private export server and check.

For further reference regarding FusionCharts supported ASP.NET private export server please visit https://www.fusioncharts.com/dev/exporting-charts/using-fc-export-server/server-side-export/setup-private-export-server-asp-net.html

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now