在IE9中将剑道图导出为Pdf

时间:2014-12-06 16:48:38

标签: kendo-ui

kendo UI图表API在ie9.Its工作正常在chrome,firefox和ie10.I没有在ie9.simply页面刷新得到任何异常。请看下面的代码不能在ie9

$("#btnExportToPDFView").click(function () {           
            // Convert the DOM element to a drawing using kendo.drawing.drawDOM
            kendo.drawing.drawDOM($(".content-wrapper"))
            .then(function (group) {
                // Render the result as a PDF file
                return kendo.drawing.exportPDF(group, {
                    paperSize: "auto",
                    margin: { left: "1cm", top: "1cm", right: "1cm", bottom: "1cm" }
                });
            })
            .done(function (data) {
                // Save the PDF file
                kendo.saveAs({
                    dataURI: data,
                    fileName: "Reports.pdf"
                    //proxyURL: "http://demos.telerik.com/kendo-ui/service/export"
                });
            });
        });

1 个答案:

答案 0 :(得分:3)

kendo文档here表示IE9要求使用您在代码中注释掉的proxyURL。您将需要一种服务,可以“使用set”Content-Disposition“标题返回已解码的文件。”

以下是您可以使用的Web服务示例:

var response = System.Web.HttpContext.Current.Response;
var request = System.Web.HttpContext.Current.Request;

var fileName = request.Params["fileName"];
var contentType = request.Params["contentType"];
var encodedString = request.Params["base64"];
byte[] bytes = Convert.FromBase64String(encodedString);

response.Clear();
response.ClearHeaders();
response.ContentType = contentType;

response.AddHeader("Content-Disposition", "attachment; filename=\"" + fileName);
response.OutputStream.Write(bytes,0,bytes.Length);

response.Flush();
response.End();