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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Grid export PDF/Print

Thread ID:





127095 Oct 25,2016 10:37 PM UTC Oct 26,2016 10:00 AM UTC ASP.NET MVC 1
Tags: Grid
Steve Lei
Asked On October 25, 2016 10:37 PM UTC


I am facing the columns cut off on printing/PDF challenge. 
Could you recommend what is the better way to define page margin and size when using print and PDF from Grid? 
And if there are more columns or like Email address column need more space, does the print and PDF button function can auto fit in a page or code need to handle each column size? 
Would you have better solution to recommend this type of challenge?

Thank you.

Ragavee U S [Syncfusion]
Replied On October 26, 2016 10:00 AM UTC

Hi Steve, 

Thanks for your interest in Syncfusion products. 

While exporting, the columns will be shown based on the columns width of the Grid. This is the default behavior of exporting. To overcome this problem, use below workaround. In this workaround, we have divided the document width by number of columns and then we have applied calculated width into all grid columns width. Please refer to the below code example.    

public void ExportToPdf(string GridModel)  
            PdfExport exp = new PdfExport();  
            var DataSource = newNorthwindDataContext().OrdersViews.Take(50).ToList();  
            GridProperties obj = ConvertGridObject(GridModel);  
            PdfDocument document = new PdfDocument();  
            var marginWidth = document.PageSettings.Margins; // here we will get page margin sizes  
            var size = ((Math.Round(document.PageSettings.Size.Width)) - (marginWidth.Top + marginWidth.Bottom + marginWidth.Left + marginWidth.Right)); // here we will get document size without margin margin size  
            var width = Math.Round(size / obj.Columns.Count);  
            for (int i = 0; i < obj.Columns.Count; i++)  
                obj.Columns[i].Width = width; // here we have applied calculated width for all columns.  
            exp.Export(obj, DataSource, "Export.pdf"falsefalse"flat-saffron",falsefalsedocument"Grid"false);//here, the 11th parameter is "isAutoFit" which we have set as false.              

Ragavee U S. 


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon