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
close icon

Positioning Exported Grid and fit the colums

Hi , 
I am facing a problem with positioning the exported grid in the pdf file , I need to set the top margin to 200px for instance , but the exported grid cover the header of the file , 
also I need to set all the columns to be fit in the documents .



 

1 Reply

JK Jayaprakash Kamaraj Syncfusion Team August 17, 2016 09:50 AM UTC

Hi Ahmad, 

Thank you for contacting Syncfusion support. 

While exporting the grid to PDF, we can change the Margin top of the page as “200” by using the below code example. 
   
public void ExportToPdf(string GridModel) 
        { 
            PdfExport exp = new PdfExport(); 
            PdfDocument document = new PdfDocument(); 
            document.PageSettings.Margins.Top =  200; // set Margin top value 
 
            var DataSource = new NorthwindDataContext().OrdersViews.Take(100).ToList(); 
            GridProperties obj = ConvertGridObject(GridModel); 
            exp.Export(obj, DataSource, "Export.pdf", false, false, "flat-saffron", false, false, document, "Grid", false);//here, the 11th parameter is "isAutoFit" which we have set as false.             
        } 

 
We can fit all the Grid columns in a single page by passing the isAutoFit parameter as false to the export method of the PdfExport Class. By default, the isAutoFit property is true. Please refer to the below code example and sample.  
public void ExportToPdf(string GridModel) 
        { 
.. 
            exp.Export(obj, DataSource, "Export.pdf", false, false, "flat-saffron", false, false, document, "Grid", false);//here, the 11th parameter is "isAutoFit" which we have set as false.             
        } 


Regards, 

Jayaprakash K. 


Loader.
Live Chat Icon For mobile
Up arrow icon