This is a migrated thread and some comments may be shown as answers.

Extra spacing in PDF export

5 Answers 218 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Kjell
Top achievements
Rank 1
Kjell asked on 25 Jan 2012, 09:09 PM
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?

5 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 26 Jan 2012, 03:48 PM
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 >>

0
Kjell
Top achievements
Rank 1
answered on 28 Jan 2012, 12:04 AM

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, " ");


0
Kjell
Top achievements
Rank 1
answered on 31 Jan 2012, 06:36 AM
bump?
0
Accepted
Dimitrina
Telerik team
answered on 31 Jan 2012, 08:46 AM
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 >>

0
Kjell
Top achievements
Rank 1
answered on 31 Jan 2012, 05:51 PM
That did the trick, thanks!
Tags
GridView
Asked by
Kjell
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Kjell
Top achievements
Rank 1
Share this question
or