Setting column width in percentage in ExportPdf

7 posts, 0 answers
  1. John John
    John John avatar
    132 posts
    Member since:
    Aug 2009

    Posted 01 Mar 2010 Link to this post

    Hi,
           How can i Set the column width in percentage in Export Pdf. I could set the column width in pixels and also it is worked in pdf file.
    But i need to set the width in % because my all of the column widths are measured in %.

    I used the same way of fixing the width in pixels but in % it is not working..

    -Thanks
  2. John John
    John John avatar
    132 posts
    Member since:
    Aug 2009

    Posted 03 Mar 2010 Link to this post

    Hi,
            Any one please suggest me for my given question?

    -Thanks
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. robertw102
    robertw102 avatar
    265 posts
    Member since:
    Jul 2007

    Posted 03 Mar 2010 Link to this post

    If you've set you column widths in percentage in you RadGrid then they will be used when you export it to pdf. Is this not the case?
  5. John John
    John John avatar
    132 posts
    Member since:
    Aug 2009

    Posted 04 Mar 2010 Link to this post

    Hi,
        Yes, my all column widths are measured in percentage. But the look and feel of PDF file is not good. Because the width is not getting as i am given in percenatege. So how can I give column width in percenatgae to export PDF file.

    I used the below code, but no use.

    RadGrid1.MasterTableView.GetColumn(
    "URL").HeaderStyle.Width = Unit.Percentage(5);

    -Thanks

  6. Daniel
    Admin
    Daniel avatar
    4945 posts

    Posted 04 Mar 2010 Link to this post

    Hello John,

    I'm afraid that column widths in percentage are not supported by RadGrid's PDF parser. You can manually convert the percentages to absolute units as demonstrated in the attached demo.

    Regards,
    Daniel
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  7. John John
    John John avatar
    132 posts
    Member since:
    Aug 2009

    Posted 05 Mar 2010 Link to this post

    Hi Daniel,
            Thanks for your reply. But it shows an error in measurement because i am giving PDF width and height in inches and margins in pixels. So it returns negative value and shows the "Width must be non negative" error.
    I am also having the feature of exporting excel in addition of exporting PDF. So width need to be measured in percenatage in excel file also.So what measurement logic can be applied for excel file.

    Else is there any conversion scenario to convert the percenate to equal to pixel.

    Regards,
    John


  8. Daniel
    Admin
    Daniel avatar
    4945 posts

    Posted 10 Mar 2010 Link to this post

    Hello John,

    I'm not sure that I understand what is the point to set the page size and margin in different units? Nevertheless, you can modify the code to calculate the columns with whatever units you use.

    To achieve the same functionality in HTML Excel, you should modify the code this way:
    protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridHeaderItem && isExport)
        {
            GridHeaderItem item = e.Item as GridHeaderItem;
            foreach (GridColumn col in RadGrid1.MasterTableView.Columns)
            {
                if (col.HeaderStyle.Width.Type == UnitType.Percentage)
                {
                    double size = RadGrid1.Width.Value;
                    Unit unit = new Unit(size * col.HeaderStyle.Width.Value / 100, RadGrid1.Width.Type);
                    col.HeaderStyle.Width = unit;
                }
            }
        }
    }

    Kind regards,
    Daniel
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017