Export to PDF onPDFExport unknown paperSize.

1 Answer 187 Views
PDFViewer
Andrew
Top achievements
Rank 1
Andrew asked on 07 May 2021, 02:22 AM

How to define the paperSize in the onPDFExport function? Currently getting the error unknown paperSize. Variable width is the total width of all of the columns in the grid, and it is not undefined.

Current code:

    function onPDFExport(e) {
        var grid = $("#CustomerOrderYearlyAllGrid").data("kendoGrid");
        var width = 0;
        for (var i = 0; i < this.columns.length; i++) {
            this.autoFitColumn(i);
            width = width + this.columns[i].width;
        }

        debugger;
        var CustomerID = $("#CustomerID").data('kendoDropDownList');
        var selectedCustomerName = CustomerID.text();
        grid.options.pdf.fileName = selectedCustomerName + " Summary (Yearly).pdf";
        grid.options.pdf.paperSize = (width + "px","500px");


    }

 

1 Answer, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 11 May 2021, 12:57 PM

Hello Andrew,

 

Thank you for writing to us.

I am afraid it is not possible to achieve this requirement using the current approach. By default, the paperSize is auto which makes the PDF logic to calculate its own size:
https://docs.telerik.com/kendo-ui/api/javascript/ui/grid/configuration/pdf.papersize

If you want to change it depending on some user selection, replace the built-in Export button of the grid with your own Export button.

Then, you will need to use the setOptions() method to change the pageSize:
https://docs.telerik.com/kendo-ui/api/javascript/ui/grid/methods/setoptions

And finally, you can call the saveAsPDF() method:

https://docs.telerik.com/kendo-ui/api/javascript/ui/grid/methods/saveaspdf 

Regards,
Eyup
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
PDFViewer
Asked by
Andrew
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Share this question
or