2016-11-17 87 views
0

我想导出剑道编辑器的内容与pdfExport事件,并另外添加索姆文本作为标题。pdf导出剑道编辑器

我最终要回到最初的内容值。

我试图使用e.promise.done作为事件来检测导出终止。

  var meetingsEditorParams = { 
       tools: ['bold', 'italic', 'underline', 'strikethrough', 'justifyLeft', 'justifyCenter', 'justifyRight', 'justifyFull', 'insertUnorderedList', 'insertOrderedList', 'indent', 'outdent', 'createTable', 'addRowAbove', 'addRowBelow', 'addColumnLeft', 'addColumnRight', 'deleteRow', 'deleteColumn', 'formatting' ,'pdf'], 

       stylesheets: ["../../../../Content/css/pdf-export-styles.css"], 
       pdf: { 
        fileName: "RECAP-TO-PRINT : " + self.fileName + ".pdf",   
        paperSize: "a4", 
        margin: { 
         bottom: 20, 
         left: 20, 
         right: 20, 
         top: 20 
        } 
       }, 
       pdfExport: function (e) { 

      //add the header to the original content and export it 
      self.meetingEditor.value("Header To Insert" + self.Content()); 
      // go back to the original content after the export 
      e.promise.done(self.meetingEditor.value(self.Content())); 

       } 
       , 
       change: function (e) { 
        console.log(self.meetingEditor.value()); 
        self.Content(self.meetingEditor.value()); 
       } 
      }; 

      self.meetingEditor = $("#meetingEditor").kendoEditor(meetingsEditorParams).data("kendoEditor"); 

问题是我总是得到原始内容导出,并忽略头。

回答

0

我认为你不能在那里更改PDF内容,到时pdfExport()被称为它可能为时已晚。

您可以使用$("#yourEditor").getKendoEditor().saveAsPDF()自定义按钮而不是内置的PDF导出按钮来生成PDF。在此之前,无论如何你都可以改变它,你希望它看起来在生成的PDF,然后在承诺完成后,你可以改回它。

这样的事情,也许(没有测试):

$("#btnPdfExport").kendoButton({ 
    click:function(){ 
    // change it here 
    $("#yourEditor").getKendoEditor().saveAsPDF(); 
    } 
}); 

然后在说pdfExport事件你可以改变它回来时的承诺就像是在问题的代码来完成。