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;
}