【问题标题】:Downloading PDF for IE9 using anychart使用anychart为IE9下载PDF
【发布时间】:2018-02-09 19:07:24
【问题描述】:

我正在尝试使用 anychart 将我的图表保存为 PDF,它在 IE9 上运行良好,但不适用于 IE9。 Anychart 是否支持 IE9 导出 PDF。

【问题讨论】:

    标签: anychart


    【解决方案1】:

    是的,AnyChart 支持 IE9(测试为 9.0.8112.16421)导出 PDF,请在 IE9 中尝试以下示例。可以从上下文菜单(“另存为 PDF”)和 API 方法(单击左上角的标签)中导出为 PDF。

        <!DOCTYPE html>
    <html lang="en">
    <head>
        <script src="https://cdn.anychart.com/releases/8.1.0/js/anychart-bundle.min.js"></script>
        <script src="https://cdn.anychart.com/releases/8.1.0/js/anychart-exports.min.js"></script>
        <style>
            html, body, #container {
                width: 100%;
                height: 100%;
                margin: 0;
                padding: 0;
            }
        </style>
    </head>
    <body>
    <div id="container"></div>
        <script>
            anychart.onDocumentReady(function () {
                var stage = anychart.graphics.create("container");
    
                var chart = anychart.line([
                    {x: "January", value: 49},
                    {x: "February", value: 45},
                    {x: "March", value: 9},
                    {x: "April", value: 4},
                    {x: "May", value: 17}
                ]);
                chart.left("5%");
                chart.title("Save chart as PDF file");
                chart.container(stage);
                chart.draw();
    
                var customLabel = anychart.standalones.label();
                customLabel.background({fill: "#9E9E9E"});
                customLabel.text("Save image");
                customLabel.fontColor("#fff");
                customLabel.padding(5);
                customLabel.offsetX(5);
                customLabel.listen("click", function () {
                    // Saves into PDF file.
                    chart.saveAsPdf("a4", true, 100, 50, "PdfChart");
    
                });
                customLabel.listen("mouseOver", function () {
                    document.body.style.cursor = "pointer";
                });
                customLabel.listen("mouseOut", function () {
                    document.body.style.cursor = "auto";
                });
                customLabel.container(stage);
                customLabel.draw();
            });
        </script>
    </body>
    </html>
    

    【讨论】:

    • 我尝试使用 chart.saveAsPdf("a4", true, 100, 50, "PdfChart") 但它让我出错,说 object expected and stage is undefined 。而且上面的例子在我刚刚检查过的任何IE版本中都没有保存pdf。
    【解决方案2】:

    这是在 IE9 中对上面示例的测试,导出为 PDF 效果很好。请尝试与测试中相同的构建 - 9.0.8112.16421

    【讨论】:

    • 我们已经与 anychart 团队核实过,他们告诉我们,他们目前不支持 IE9 导出 PDF。
    猜你喜欢
    • 1970-01-01
    • 2015-03-27
    • 1970-01-01
    • 2011-09-01
    • 2020-10-10
    • 2013-10-14
    • 2016-07-26
    • 2016-07-10
    • 2013-10-09
    相关资源
    最近更新 更多