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

Text Wrap Grid to PDF Export

Thread ID:

Created:

Updated:

Platform:

Replies:

124067 May 12,2016 07:19 PM UTC May 13,2016 09:50 AM UTC JavaScript 1
loading
Tags: ejGrid
Lory
Asked On May 12, 2016 07:19 PM UTC

Hi Team,

I have a grid with allowTextWrap settings set to true, the width for each column is also defined. This grid can be exported to PDF.
However when I export it to PDF, not all of the columns fit into an A4 landscape page. The reason is that there are columns that are quite lengthy and take up a lot of the width.

What I would like is to have a fixed width for these columns and the text inside should wrap. Is there a way to set that?

        //PDF Export Method.
        [System.Web.Http.ActionName("PdfExport")]
        [AcceptVerbs("POST")]
        public void PdfExport(IEnumerable data)
        {
            string gridModel = System.Web.HttpContext.Current.Request.Params["GridModel"];
            GridProperties gridProperty = ConvertGridObject(gridModel);
            PdfExport exp = new PdfExport();
            
            PdfDocument document = new PdfDocument();
            document.PageSettings.Orientation = PdfPageOrientation.Landscape;
            document.PageSettings.Size = PdfPageSize.A4;

            //Settings for text wrap?

            exp.Export(gridProperty, data, "Export.pdf", false, false, "flat-saffron", false, document, "Grid");
        }


        //Grid Model conversion Method.
        private GridProperties ConvertGridObject(string gridProperty)
        {
            JavaScriptSerializer serializer = new JavaScriptSerializer();
            IEnumerable div = (IEnumerable)serializer.Deserialize(gridProperty, typeof(IEnumerable));
            GridProperties gridProp = new GridProperties();
            foreach (KeyValuePair<string, object> ds in div)
            {
                var property = gridProp.GetType().GetProperty(ds.Key, BindingFlags.Instance | BindingFlags.Public | BindingFlags.IgnoreCase);
                if (property != null)
                {
                    Type type = property.PropertyType;
                    string serialize = serializer.Serialize(ds.Value);
                    object value = serializer.Deserialize(serialize, type);
                    property.SetValue(gridProp, value, null);
                }
            }
            return gridProp;
        }

Jayaprakash Kamaraj [Syncfusion]
Replied On May 13, 2016 09:50 AM UTC

Hi Lory, 

Thank you for contacting Syncfusion support. 

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.   
 
[System.Web.Http.ActionName("PdfExport")] 
        [AcceptVerbs("POST")] 
        public void PdfExport() 
        { 
            …. 
           exp.Export(gridProperty, result, "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. 


CONFIRMATION

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

or the page will be automatically redirected to 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

;