This is a migrated thread and some comments may be shown as answers.

Kendo Grid PDFExport does not apply template with paperSize "auto"

1 Answer 389 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Taha
Top achievements
Rank 1
Taha asked on 22 Jan 2021, 05:27 PM

I am using Kendo grid jquery option pdf export and I am noticing that it does not apply template when the paperSize is set to "auto", however when I change it to "A4" it does apply.

Can anyone guide me what is the problem with "auto" ? I have a wide grid that cuts off when I set "A4" or "A3" with the landscape mode.

1 Answer, 1 is accepted

Sort by
0
Alex Hajigeorgieva
Telerik team
answered on 26 Jan 2021, 01:43 PM

Hello, Taha,

For the page template to work, it requires the use of either a pageSize or another page breaking mechanism such as the forcePageBreak:

https://docs.telerik.com/kendo-ui/framework/drawing/pdf-output/page-templates

Some things you can do to work around this specification:

  • Provide a non-existent selector in the forcePageBreak property.

Runnable example: https://dojo.telerik.com/ENEXuSaH

  • Set the paperSize option to a precalculated width and height

          Runnable example:   https://dojo.telerik.com/@bubblemaster/UmOZoLiM

     var width = $("#my-element").width() + "pt";
    var height = $("#my-element").height() + "pt";
    kendo.drawing.drawDOM("#myelement", {
              multiPage:false,
              paperSize:[width, height],
              margin:"2.5cm",
              scale:.7,
              template: $("#page-template").html()
    }).then(function(group){
              group.options.pdf.multiPage = false;
              kendo.drawing.pdf.saveAs(group, "filename.pdf");
    });

Kind Regards,
Alex Hajigeorgieva
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
Grid
Asked by
Taha
Top achievements
Rank 1
Answers by
Alex Hajigeorgieva
Telerik team
Share this question
or