2014-07-23 2 views
0

J'essaie d'obtenir des graphiques de png en png ou pdf avec Inkspace.Inkscape pour exporter les caractères png unicode ne semble pas

Mais j'ai un problème avec le titre de Chart. J'utilise des caractères turcs et je ne peux pas montrer les caractères turcs sur la section du titre. Comment puis-je résoudre ce problème?

Merci.

// voici le code:

private const string INKSCAPE_PATH = @"C:\Program Files (x86)\Inkscape\inkscape.exe"; 
     private const int WIDTH = 800; 
     private const int HEIGHT = 600; 


     private readonly Dictionary<KendoChartExport.Models.ExportFormat, string> MimeTypes = new Dictionary<KendoChartExport.Models.ExportFormat, string> 
     { 
      { KendoChartExport.Models.ExportFormat.PNG, "image/png" }, 
      { KendoChartExport.Models.ExportFormat.PDF, "application/pdf" } 
     }; 



     [HttpPost] 
     public ActionResult _Export(string svg, KendoChartExport.Models.ExportFormat format) 
     { 

      var svgText = HttpUtility.UrlDecode(svg); 
      var svgFile = TempFileName() + ".svg"; 
      System.IO.File.WriteAllText(svgFile, svgText); 

      var outFile = DoExport(svgFile, format); 
      var attachment = "export" + System.IO.Path.GetExtension(outFile); 

      return File(outFile, MimeTypes[format], attachment); 
     } 

     private string DoExport(string svgFile, KendoChartExport.Models.ExportFormat format) 
     { 

      var extension = format == KendoChartExport.Models.ExportFormat.PNG ? "png" : "pdf"; 
      var outFile = TempFileName() + "." + extension; 
      var inkscape = new System.Diagnostics.Process(); 
      inkscape.StartInfo.FileName = INKSCAPE_PATH; 
      inkscape.StartInfo.Arguments = 
       String.Format("--file \"{0}\" --export-{1} \"{2}\" --export-width {3} --export-height {4}", 
           svgFile, extension, outFile, WIDTH, HEIGHT); 
      inkscape.StartInfo.UseShellExecute = true; 
      inkscape.Start(); 

      inkscape.WaitForExit(); 

      return outFile; 
     } 

     private string TempFileName() 
     { 
      return System.IO.Path.Combine(Server.MapPath("~/App_Data"), System.IO.Path.GetRandomFileName()); 
     } 


     #endregion 


    } 

Répondre

0

Solution, changement action _export;

[HttpPost] 
     public ActionResult _Export(string svg, KendoChartExport.Models.ExportFormat format) 
     { 
      var abc = Encoding.GetEncoding("UTF-8"); 
      svg = svg.Replace("%F6", "ö"); 
      svg = svg.Replace("%D6", "Ö"); 

      svg = svg.Replace("%C7", "Ç"); 
      svg = svg.Replace("%E7", "ç"); 

      svg = svg.Replace("%DC", "Ü"); 
      svg = svg.Replace("%FC", "ü"); 

      svg = svg.Replace("F0", "ğ"); 
      svg = svg.Replace("D0", "Ğ"); 

      svg = svg.Replace("DD", "İ"); 
      svg = svg.Replace("%FD", "ı"); 

      var svgText = HttpUtility.UrlDecode(svg, abc); 
      var svgFile = TempFileName() + ".svg"; 
      System.IO.File.WriteAllText(svgFile, svgText); 

      var outFile = DoExport(svgFile, format); 
      var attachment = "export" + System.IO.Path.GetExtension(outFile); 

      return File(outFile, MimeTypes[format], attachment); 
     } 
Questions connexes