【问题标题】:pdf export of kendo-editorkendo-editor的pdf导出
【发布时间】:2016-11-17 11:50:08
【问题描述】:

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

最后我想回到原始值,即第一个内容。

我尝试使用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");

问题是我总是导出原始内容并且它忽略了标题。

【问题讨论】:

    标签: javascript kendo-ui pdf-generation


    【解决方案1】:

    我认为您无法在此处更改 PDF 内容,当 pdfExport() 被调用时可能为时已晚。

    您可以在单击自定义按钮时使用$("#yourEditor").getKendoEditor().saveAsPDF(),而不是使用内置的 PDF 导出按钮来生成您的 PDF。在此之前,您可以随意更改它,使其在生成的 PDF 中查看,然后在完成承诺后,您可以将其更改回来。

    可能是这样的(还没有测试过):

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

    然后在说pdfExport 事件时,您可以在承诺完成时将其更改回来,就像问题中的代码一样。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-12-11
      • 1970-01-01
      • 1970-01-01
      • 2021-01-23
      • 2018-04-21
      • 1970-01-01
      相关资源
      最近更新 更多