Extra spacing in PDF export

6 posts, 1 answers
  1. Kjell
    Kjell avatar
    283 posts
    Member since:
    Jun 2010

    Posted 25 Jan 2012 Link to this post

    Hi.  I am generating a PDF from the contenst of a radgridview using RadDocument.  This is a feature which has been part of my application for a couple years and does not get tested much on my end because I don't usually make changes to it. 

    Recently I noticed that the header of my report has extra space in it, basically it looks like there is an extra blank line in between each line of text (there are 3 lines). 

    This is the code which generates the header:
    var headtable = new Table(1, 2);
                   var table = new Table(1, 5);
     
                   var document = new RadDocument();
                   document.Sections.Add(new Telerik.Windows.Documents.Model.Section());
                   document.LineSpacing = 1;
     
                   headtable.CellPadding = new Telerik.Windows.Documents.Layout.Padding(0); ;
                   headtable.CellSpacing = 0;
     
     
                   //report header
                   document.Sections.First.Blocks.Add(headtable);
                   //col 1
                   var headCell = headtable.Rows.First.Cells.First;
                   headCell.Borders.All = new Telerik.Windows.Documents.Model.Border(BorderStyle.None, Colors.Black);               
                   AddCellDataSpan(headCell, App.RunForName, Colors.Transparent, Colors.Black, Telerik.Windows.Documents.Layout.RadTextAlignment.Left);
                   AddCellDataSpan(headCell, "Run: " + DateTime.Now.ToString("M/dd/yyyy h:mm tt"));
                   AddCellDataSpan(headCell, "Range: " + App.startDate + " to " + App.endDate);
                   AddCellDataSpan(headCell, " ");
                   //col2
                   headCell = (TableCell)headCell.NextSibling;
                   headCell.Borders.All = new Telerik.Windows.Documents.Model.Border(BorderStyle.None, Colors.Black);
                   AddCellDataSpan(headCell, App.companyName, Colors.White, Colors.Black, Telerik.Windows.Documents.Layout.RadTextAlignment.Right);
                   AddCellDataSpan(headCell, reportname + " Report", Colors.White, Colors.Black, Telerik.Windows.Documents.Layout.RadTextAlignment.Right);
                   //AddCellDataSpan(headCell, " ");
                   //AddCellDataSpan(headCell, " ");


    What I am expecting to see, and I think used to see is basically 3 lines of text one on top of the other.  But what I am getting is what looks like 6 lines of text with a blank in between each of my lines.  Though I think it's actually a line spacing issue, I don't think a carriage return is being entered erroniously.

    What am I doing wrong?
  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 26 Jan 2012 Link to this post

    Hello,

     Actually this empty line is expected. When you add a new table to document, a new line is added after it.

    Greetings,
    Didie
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. Kjell
    Kjell avatar
    283 posts
    Member since:
    Jun 2010

    Posted 27 Jan 2012 Link to this post

    The empty line after the table is fine, but what I want to get rid of the is the empty lines in the cell.  Each line of text is followed by an empty line, and all this is happening in a single cell.

    Instead of adding each piece of text to the cell one at a time, I tried putting it all into a string and adding it that way, but the same thing happens.  How do I get 3 lines of text into a cell, without an empty line in between them?


    Here is the new code, I just commented out the second cell completely and for now I will ignore that one until the first cell is working.

    //define text for header cell
                   string headerText = App.RunForName + Environment.NewLine;
                   headerText = headerText + "Run: " + DateTime.Now.ToString("M/dd/yyyy h:mm tt") + Environment.NewLine;
                   headerText = headerText + "Range: " + App.startDate + " to " + App.endDate;
     
                   //col 1
                   var headCell = headtable.Rows.First.Cells.First;
                   headCell.Borders.All = new Telerik.Windows.Documents.Model.Border(BorderStyle.None, Colors.Black);
                   AddCellDataSpan(headCell, headerText, Colors.Transparent, Colors.Black, Telerik.Windows.Documents.Layout.RadTextAlignment.Left);
                   //AddCellDataSpan(headCell, "Run: " + DateTime.Now.ToString("M/dd/yyyy h:mm tt"));
                   //AddCellDataSpan(headCell, "Range: " + App.startDate + " to " + App.endDate);
                   AddCellDataSpan(headCell, " ");


  4. Kjell
    Kjell avatar
    283 posts
    Member since:
    Jun 2010

    Posted 31 Jan 2012 Link to this post

    bump?
  5. Answer
    Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 31 Jan 2012 Link to this post

    Hello,

    Indeed you are right that an additional new line is added. Please use the 

    FormattingSymbolLayoutBox.LINE_BREAК

    instead of "Environment.NewLine".

    Does this do the trick?

    Regards,
    Didie
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  6. Kjell
    Kjell avatar
    283 posts
    Member since:
    Jun 2010

    Posted 31 Jan 2012 Link to this post

    That did the trick, thanks!
Back to Top