2016-11-17 86 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事件你可以改變它回來時的承諾就像是在問題的代碼來完成。