Asp.net mvc 用于导出png unicode字符的Inkscape似乎不可用
我正在尝试使用Inkspace将剑道图表转换为png或pdf格式 但我对图表的标题有问题。我使用的是土耳其语字符,我不能在标题部分显示土耳其语字符。我怎样才能解决这个问题 多谢各位 //代码如下:Asp.net mvc 用于导出png unicode字符的Inkscape似乎不可用,asp.net-mvc,unicode,svg,kendo-ui,inkscape,Asp.net Mvc,Unicode,Svg,Kendo Ui,Inkscape,我正在尝试使用Inkspace将剑道图表转换为png或pdf格式 但我对图表的标题有问题。我使用的是土耳其语字符,我不能在标题部分显示土耳其语字符。我怎样才能解决这个问题 多谢各位 //代码如下: private const string INKSCAPE_PATH = @"C:\Program Files (x86)\Inkscape\inkscape.exe"; private const int WIDTH = 800; private const i
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
}
解决方案、变更和出口行动
[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);
}