抓取 Kendo 电子表格和所见即所得编辑器 PDF 导出 dataURI

Grabbing Kendo Spreadsheet & WYSIWYG Editor PDF Export dataURI

有没有办法像 Kendo 甘特图小部件一样从 pdf 导出的 Kendo 电子表格和所见即所得编辑器小部件中获取 base64 dataURI?

我引用了这个 Kendo UI Dojo Example as well as the Telerik forum question "Get Base64 From Export PDF"

成功从甘特图小部件获取 base64 数据的代码如下所示:

    $("#gantt").kendoGantt({
        toolbar: ["pdf"],
        dataSource: [
          {
            id: 1,
            orderId: 0,
            parentId: null,
            title: "Task1",
            start: new Date("2014/6/17 9:00"),
            end: new Date("2014/6/17 11:00")
          }
        ],
        pdfExport: function(e) {
            e.preventDefault();

            gantt._drawPDF()
              .then(function(root) {
                  return kendo.drawing.exportPDF(root, {
                      // PDF options
                  });
              })
              .done(function(dataURI) {
                  console.log(dataURI);
                  // Data URI available here
              });
         }
      });
      var gantt = $("#gantt").data("kendoGantt");

您会注意到可以在 pdfExport 对象中的此处 .done(function(dataURI){...}) 访问 dataURI。

Spreadsheet and the WYSIWYG Editor 是否有类似的东西? 我搜索了文档和论坛,但没有找到。任何帮助将不胜感激。

您可以对 Kendo UI 编辑器使用完全相同的方法,但不能对电子表格使用。

这已通过编辑器 API 中的以下代码片段解决:

$("#editor").kendoEditor({
        tools: ["pdf"],
        value: "sample editor data"
    }
});

var editor = $("#editor").data("kendoEditor");

editor._drawPDF()
    .then(function(root) {
        return kendo.drawing.exportPDF(root, {});
    })
    .then(function(dataURI) {
        console.log(dataURI);
});

看起来我们能够将代码减少到最低限度,并且它按照我们需要的方式运行。这是 Kendo 提供的工作演示的 link:Dojo

请注意,代码使用的内部方法似乎与它们的 PublicAPI.

无关

至于电子表格...他们为此功能打开了功能请求票。我们使用他们的服务器端 API 来生成 PDF 信息,因为似乎没有办法通过 JavaScript API.

获取 dataURI