New to Kendo UI for jQuery? Download free 30-day trial

Getting Started with PDF Export

This guide demonstrates how to use the Kendo UI for jQuery Drawing Library to export the content of a page to a PDF file.

After the completion of this guide, you will achieve the following result:

Open In Dojo

1. Draw the Scene

Use the Drawing API to generate a drawing of the current scene.

kendo.drawing.drawDOM("#container");

2. Configure the Options of the PDF

Set some of the options such as margins, landscape mode, and paper size:

 kendo.drawing.drawDOM("#container", {
    margin: "2px", // configure some of the PDF options.
    paperSize: "A3",
    landscape: true,
    multiPage: true
 });

3. Export the Scene to PDF

Export the generated scene to a PDF file:

.then(function(group){
    kendo.drawing.pdf.saveAs(group, "filename.pdf");
});

(Optional) 4. Convert to Data URI or Blob

You can convert the generated PDF to Data URI or a Blob. By doing so you can attach the file to a form that can be submitted later on.

    kendodrawing.pdf.toBlob(group, function(blob){
        // You can now upload it to a server.
        // This form simulates an <input type="file" name="pdfFile" />.
        var form = new FormData();
        form.append("pdfFile", blob);

        var xhr = new XMLHttpRequest();
        xhr.open("POST", "/posturl", true);
        xhr.send(form);
    });

    // Alternatively, you can get it as a data URL.
    kendo.drawing.pdf.toDataURL(group, function(dataURL){ ... });

Next Steps