剑道出口为PDF格式

时间:2016-01-11 12:59:42

标签: asp.net-mvc pdf kendo-ui

我在#PrintPDF按钮中调用了kendo.drawing.drawDOM方法。单击按钮时,按钮单击成功,我得到部分视图结果。现在我想将此部分视图结果传递给pdf文档。我不知道如何将部分视图结果作为kendo.drawing.drawDOM的输入元素传递。

注意:$ .parseHTML(结果)不起作用。

$("#PrintPDF").click(function () {         

        var url = "_PrintPDFPartialView";
        $.ajax({
            url: url,
            type: 'POST',
            data: {
                id: $("#StId").val()
            },   
     success: function (result) 
           {
             kendo.drawing.drawDOM($.parseHTML(result))
             .then(function (group) {
                 // Render the result as a PDF file
                 return kendo.drawing.exportPDF(group, {
                     paperSize: "auto",
                     multiPage: true,   
                     });
                 }).done(function (data) {    },
                    )};
           });

1 个答案:

答案 0 :(得分:0)

您可以使用此source

import javax.swing.SwingUtilities;

import org.apache.tools.ant.BuildEvent;
import org.apache.tools.ant.DefaultLogger;  


/*
 * This class has been wrote to deals with ant build outputs.
 * 
 * However, buildFinished and buildStarted seems not to work.
 * See details at :
 * 
 * http://api.dpml.net/ant/1.7.0/org/apache/tools/ant/DefaultLogger.html
 * 
 */
public class ExtendedLogger extends DefaultLogger {

    /*
     * public class ColorPane extends JTextPane
     * 
     * (personal class : JTextPane + Ansi coloring)
     */
    ColorPane colorPane = null;

    public ExtendedLogger(ColorPane c){
        super();
        if (c != null){
            colorPane = c;
        } else {
            System.out.println("ColorPane given to constructor is null. Exiting program.");
            System.exit(0);
        }
    }

    @Override
    public void buildFinished(BuildEvent event) {
        ColorPane.appendInEDT("[BUILD FINISHED]\n", ColorPane.B_Yellow, colorPane);
        System.out.println("Logger : "+"[BUILD FINISHED]\n");
    }

    @Override
    public void buildStarted(BuildEvent event) {
        ColorPane.appendInEDT("[BUILD STARTED]\n", ColorPane.B_Yellow, colorPane);
        System.out.println("Logger : "+"[BUILD STARTED]\n");
    }


    @Override
    public void log(String message){
        appendInEDT(message);
    }

    private void appendInEDT(String s){
        /*
         * Detach the graphical modifications in the Event Dispatch Thread (EDT)
         */
        final String newLine = s;
        Thread t = new Thread(new Runnable(){
            public void run(){
                colorPane.append(ColorPane.B_White, newLine+"\n");
            }
        });
        if (SwingUtilities.isEventDispatchThread()) {
            t.start();
        } else {
            SwingUtilities.invokeLater(t);
        }
    }
}