We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How can I change a layout to export to pdf in ASP.NET MVC Grid

Hi,

How can I change a layout to export to pdf?
Because when I export a grid to pdf, the file have 3 pages, the correct is one page.

1 Reply

LR Logesh Rajappa Syncfusion Team June 19, 2018 11:06 AM UTC

Hi Thomaz, 

Thanks for using Syncfusion products. 

Query: “How can I change a layout to export to pdf? 
 
We have analyzed your query and the layout of the pdf export can be changed by changing the pdf - exportProperties pageOrientation to “Landscape”. Also In the pdf export, columns splits into multiple pages when number of columns is more than the view port size. The default behavior of the pdf export is to export grid columns according to the width of the page. So we suggest you to use “landscape” pageOrientation to achieve your requirement. We have given a sample and a documentation link for your reference. 

Code Example

[index.cshtml] 
@Html.EJS().Grid("Grid").DataSource((IEnumerable<object>)ViewBag.dataSource).ToolbarClick("toolbarClick").Columns(col => 
            { 
                col.Field("OrderID").HeaderText("Order ID").Width("130").TextAlign(Syncfusion.EJ2.Grids.TextAlign.Right).Add(); 
... 
            }).AllowPaging().AllowPdfExport(true).PageSettings(page => page.PageCount(2)).Toolbar(new List<string>() { "PdfExport" }).Render() 
... 
<script> 
    function toolbarClick(args) { 
        var gridObj = document.getElementById("Grid").ej2_instances[0]; 
        if (args.item.id === 'Grid_pdfexport') { 
            var exportProperties = { 
                pageOrientation: 'Landscape', 
            }; 
            gridObj.pdfExport(exportProperties); 
        } 
    } 
</script> 



Please get back to us for further assistance. 

Regards, 
Logesh R 


Loader.
Live Chat Icon For mobile
Up arrow icon