Higcharts derived Chinese garbled

Today highcharts export picture, meet Chinese garbled problem, finally use
import org.apache.batik.transcoder.Transcoder;
import org.apache.batik.transcoder.TranscoderInput;
import org.apache.batik.transcoder.TranscoderOutput;
import org.apache.batik.transcoder.image.JPEGTranscoder;
import org.apache.batik.transcoder.image.PNGTranscoder;
import org.apache.fop.svg.PDFTranscoder;
To solve the problem, but from the picture is not very clear, no highcharts own picture clearly, may I ask how to solve good?
Here is the code

HttpServletRequest request = this.getRequest();
HttpServletResponse response = this.getResponse();
try
{
ServletOutputStream out = response.getOutputStream();
request.setCharacterEncoding("utf-8");
// Note code
String type = request.getParameter("type");
String svg = request.getParameter("svg");
if (null != type && null != svg)
{
svg = svg.replaceAll(":rect", "rect");
String ext = "";
Transcoder t = null;

if (type.equals("image/png"))
{
ext = "png";
t = new PNGTranscoder();

}
else if (type.equals("image/jpeg"))
{
ext = "jpg";
t = new JPEGTranscoder();

}
else if (type.equals("application/pdf"))
{
ext = "pdf";
t = new PDFTranscoder();
}
else if (type.equals("image/svg+xml"))
{
ext = "svg";
}

response.addHeader("Content-Disposition",
"attachment; filename=chart." + ext);
response.addHeader("Content-Type", type);

if (null != t)
{
TranscoderInput input = new TranscoderInput(
new StringReader(svg));
TranscoderOutput output = new TranscoderOutput(out);
try
{
System.out.println(input.getReader());
t.transcode(input, output);
}

Started by Gwendolyn at February 10, 2016 - 10:04 AM

You can try this

Need to reference the svg.dll an open source project connected yourself
Itextsharp.dll provides Chinese support

using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using Svg;
using System.Drawing.Imaging;
using iTextSharp.text;
using iTextSharp.text.pdf;
using System.Text;
namespace ExportServer
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
if (Request.Form["type"] != null && Request.Form["svg"] != null && Request.Form["filename"] != null)
{
string tType = Request.Form["type"].ToString();
string tSvg = Request.Form["svg"].ToString();
string tFileName = Request.Form["filename"].ToString();
if (tFileName == "")
{
tFileName = "chart";
}
MemoryStream tData = new MemoryStream(Encoding.UTF8.GetBytes(tSvg));
MemoryStream tStream = new MemoryStream();
string tTmp = new Random().Next().ToString();

string tExt = "";
string tTypeString = "";

switch (tType)
{
case "image/png":
tTypeString = "-m image/png";
tExt = "png";
break;
case "image/jpeg":
tTypeString = "-m image/jpeg";
tExt = "jpg";
break;
case "application/pdf":
tTypeString = "-m application/pdf";
tExt = "pdf";
break;
case "image/svg+xml":
tTypeString = "-m image/svg+xml";
tExt = "svg";
break;
}

if (tTypeString != "")
{
string tWidth = Request.Form["width"].ToString();
Svg.SvgDocument tSvgObj = SvgDocument.Open(tData);
switch (tExt)
{
case "jpg":
tSvgObj.Draw().Save(tStream, ImageFormat.Jpeg);
break;
case "png":
tSvgObj.Draw().Save(tStream, ImageFormat.Png);
break;
case "pdf":
PdfWriter tWriter = null;
Document tDocumentPdf = null;
try
{
tSvgObj.Draw().Save(tStream, ImageFormat.Png);
tDocumentPdf = new Document(new Rectangle((float)tSvgObj.Width, (float)tSvgObj.Height));
tDocumentPdf.SetMargins(0.0f, 0.0f, 0.0f, 0.0f);
iTextSharp.text.Image tGraph = iTextSharp.text.Image.GetInstance(tStream.ToArray());
tGraph.ScaleToFit((float)tSvgObj.Width, (float)tSvgObj.Height);

tStream = new MemoryStream();
tWriter = PdfWriter.GetInstance(tDocumentPdf, tStream);
tDocumentPdf.Open();
tDocumentPdf.NewPage();
tDocumentPdf.Add(tGraph);
tDocumentPdf.CloseDocument();
}
catch (Exception ex)
{
throw ex;
}
finally
{
tDocumentPdf.Close();
tDocumentPdf.Dispose();
tWriter.Close();
tWriter.Dispose();
tData.Dispose();
tData.Close();

}
break;

case "svg":
tStream = tData;
break;
}

Response.ClearContent();
Response.ClearHeaders();
Response.ContentType = tType;
Response.AppendHeader("Content-Disposition", "attachment; filename=" + tFileName + "." + tExt + "");
Response.BinaryWrite(tStream.ToArray());
Response.End();
}
}
}
}
}
}

Posted by Paddy at February 14, 2016 - 11:02 AM

Java ah.

Posted by Gwendolyn at February 24, 2016 - 11:16 AM

Prawn Java how to achieve

Posted by Gwendolyn at February 25, 2016 - 11:50 AM

The exported PDF file picture is quite clear, do not know why direct export picture.

Posted by Gwendolyn at February 26, 2016 - 12:24 PM

This problem is not solved.

Posted by Lyle at December 10, 2016 - 7:06 AM

Real wood is a good way.

Posted by Gwendolyn at December 19, 2016 - 7:07 AM

The response to 2013-11-12 08:48:02 was removed by the administrator

Posted by Gwendolyn at December 24, 2016 - 7:17 AM

Turn in. . .

Posted by Gwendolyn at January 04, 2017 - 8:15 AM

Code two, code two times in decoding, remember, UrlEncode , UrlDecode

Posted by Spencer at January 09, 2017 - 8:32 AM

Now I want to local export picture, but it is not clear, problem solving

Posted by Gwendolyn at January 14, 2017 - 9:13 AM

Prepare the Post Bar. . . . .

Posted by Gwendolyn at January 15, 2017 - 9:25 AM