SQL Server Forum / Services / Reporting Services / October 2006
Textbox Renders Incorrectly Across Multiple Pages in PDF
|
|
Thread rating:  |
Chris Walls - 21 Oct 2006 12:46 GMT We have a repot that contains a textbox that may contain a large text string with embedded line breaks. This textbox is positioned in the lower portion of page 1 of the report. We are running into a situation when the text string is long enough to cause a page break when exporting to PDF. When we convert the report to PDF (a requirement), the entire textbox is moved to page 2, leaving considerable white space on page 1. We would expect the textbox to be split across pages. We then find if the text string is larger than a single page, then the beginning portion of the string is back on page 1, with the remainder on page two. This tells us SRS can split the contents of the text box correctly across pages in some cases.
To reproduce, create a new empty report. * Add a text box with a location of 0.5in, 4in * Add 50 lines of text (we repeated "01 - The quick brown fox jumped over the lazy dogs.", incrementing the line number for easy tracking * Render the report, then export to PDF
At this point we see a blank first page and the entire text on the second page.
* Edit the report, add another 50 lines for a total of 100 * Render the report, then export to PDF At this point we see a the text starting at the appropriate location on page one, spanning page two, and ending on page three.
* Edit the report, remove 12 lines for a total of 88. * Render the report, then export to PDF At this point we see a the text starting at the appropriate location on page one, ending at the bottom of page two.
It seems the text is only positioned in the correct place on page 1 when either a) The entire text fits on page 1 b) The entire text cannot fit on page 2 in which case instead of expanding to a page 3, the top of the text is pushed back up to the desired position.
1) Why is this? I cannot find any "Keep Together" property to turn off for the textbox (what MS Word offers to keep a paragraph together) when I scroll through the list in the report designer. 2) What can I do IN REPORTING SERVICES to get around this? Manipulating the data at the source is not an option.
A note about the text: It is preformatted meaning it already contains line breaks. We've tried using different combinations of line feeds / carriage returns and it seems to have no affect on this issue. The nature of this text and this report is that it the lenght will vary depending upon the subject.
Thanks, Chris
Steve MunLeeuw - 21 Oct 2006 17:42 GMT We also take issue with how the textbox control handles page splits. We called into MS Support and ended up writing some text parsing logic. It's pretty darn rudimentary and I know it's fragile, but has worked for us so far.
We use two textboxes instead of one and feed the text field to two methods parasplit 1 and 2. Fortunately we know the font, size and so on. We have a paragraph above that varies in how many lines it takes up. We try count these and feed in how many lines we have on page 1, how many characters fit on a line, then we have logic for dealing with the fact that not all text takes up a whole line (bulleted lists). What we don't take care of is that we are using a variable width font, so all this is adds up to quite a bit of a gamble on where to split the page.
Expression for textbox1 =IIf(
CountRows("narrSchoolDescription") > 0,
CustAssembly.StaticMethods.ParaSplitFirst(
First(Fields!NarrativeText.Value, "narrSchoolDescription"),
32,
IIF(Parameters!ISSARC.Value = True, 9, 0), 100), Code.rsLoc.GetResString("common_NoData"))
Expression for textbox2
=CustAssembly.StaticMethods.ParaSplitSecond(
First(Fields!NarrativeText.Value, "narrSchoolDescription"),
32,
IIF(Parameters!ISSARC.Value = True, 9, 0), 100)
Here's the code from the custom assembly. public static string Crop(string input, int lines, int width)
{
int CropPoint = 0;
string[] TxtLines;
int LineCount = 0;
int MultiCount = 0;
System.Windows.Forms.TextBox TxtWordProcess = new System.Windows.Forms.TextBox();
//validate parameters
System.Diagnostics.Debug.Assert(null != input);
if (null == input)
throw (new ArgumentException("input parameter is null"));
TxtWordProcess.Text = input;
TxtLines = TxtWordProcess.Lines;
foreach (string TxtLine in TxtLines)
{
if (LineCount < lines)
{
if (TxtLine.Length > width)
{
MultiCount = TxtLine.Length / width;
LineCount = LineCount + MultiCount;
if (LineCount < lines)
{
CropPoint = CropPoint + TxtLine.Length + 2;
}
}
else
{
CropPoint = CropPoint + TxtLine.Length + 2;
LineCount++;
}
}
}
if (CropPoint == 0)
{
if (input.Length < (width * lines))
{
CropPoint = input.Length;
}
else
{
CropPoint = (width * lines);
}
}
if (CropPoint > input.Length)
{
CropPoint = input.Length;
}
TxtWordProcess.Dispose();
return input.Substring(0, CropPoint);
}
public static string ParaSplitFirst(string Input, int TotLines, Int32 LinesUsed, int NumCharsPerLine)
{
string First = null;
string Second = null;
ParaSplit(Input, TotLines, LinesUsed, NumCharsPerLine, ref First, ref Second);
return First;
}
public static string ParaSplitSecond(string Input, int TotLines, int LinesUsed, int NumCharsPerLine)
{
string First = null;
string Second = null;
//ParaSplit(Input, TotLines, LinesUsed, NumCharsPerLine, ref First, ref Second);
return Second;
}
public static void ParaSplit(string Input, int TotLines, int LinesUsed, int NumCharsPerLine, ref string Output1, ref string Output2)
{
int CropMe = 0;
//validation
if (Input == null) { return; }
if (LinesUsed >= TotLines)
{
CropMe = 0;
}
else
{
CropMe = CropPoint(Input, TotLines - LinesUsed, 115);
}
Output1 = Input.Substring(0, CropMe);
Output2 = Input.Substring(CropMe, Input.Length - CropMe);
}
public static int CropPoint(string Input, int Lines, int NumCharsPerLine)
{
int CropPoint = 0;
string[] TxtLines;
int LineCount = 0;
int MultiCount = 0;
System.Windows.Forms.TextBox TxtWordProcess = new System.Windows.Forms.TextBox();
//validate parameters
System.Diagnostics.Debug.Assert(null != Input);
if (null == Input)
throw (new ArgumentException("input parameter is null"));
TxtWordProcess.Text = Input;
TxtLines = TxtWordProcess.Lines;
foreach (string TxtLine in TxtLines)
{
if (LineCount < Lines)
{
if (TxtLine.Length > NumCharsPerLine)
{
MultiCount = TxtLine.Length / NumCharsPerLine;
LineCount = LineCount + MultiCount;
if (LineCount < Lines)
{
CropPoint = CropPoint + TxtLine.Length + 2;
}
}
else
{
CropPoint = CropPoint + TxtLine.Length + 2;
LineCount++;
}
}
}
if (CropPoint == 0)
{
if (Input.Length < (NumCharsPerLine * Lines))
{
CropPoint = Input.Length;
}
else
{
CropPoint = (NumCharsPerLine * Lines);
}
}
if (CropPoint > Input.Length)
{
CropPoint = Input.Length;
}
TxtWordProcess.Dispose();
return CropPoint;
}
public static int LineCount(string Input, int NumCharsPerLine)
{
int LineCount = 0;
int Count = 0;
string[] TxtLines;
System.Windows.Forms.TextBox TxtWordProcess = new System.Windows.Forms.TextBox();
//validate parameters
System.Diagnostics.Debug.Assert(null != Input);
if (null == Input)
throw (new ArgumentException("input parameter is null"));
TxtWordProcess.Text = Input;
TxtLines = TxtWordProcess.Lines;
//Loop through each line, if the line wraps, check that it spills onto a next line.
//if there isn't anything on the line, count that too.
foreach (string TxtLine in TxtLines)
{
Count = (TxtLine.Length / NumCharsPerLine);
LineCount += Count;
if (TxtLine.Length % NumCharsPerLine != 0)
{
LineCount++;
}
if (TxtLine.Length == 0)
{
LineCount++;
}
}
TxtWordProcess.Dispose();
return LineCount;
}
Steve MunLeeuw
> We have a repot that contains a textbox that may contain a large text > string with embedded line breaks. This textbox is positioned in the lower [quoted text clipped - 48 lines] > Thanks, > Chris Chris Walls - 22 Oct 2006 15:03 GMT Thanks for the tip. Based on what I'm about to report, we may have no other choice but to implement something similar.
For giggles, I artifically broke my data into rows and was able to generate a recordset of one record per line. I then added a list control that *contained* a textbox. I bound the list control to my dataset and set the textbox so that it displays one line of text, thus based on the recordset, achieves the same visual results. Per usual rendering the report in HTML works just fine. However, to my surprise when I exported it to PDF, I see the same erroneous behavior - a blank first page and all the text on the second page. I confirmed the list control's "KeepTogether" attribute was set to false.
I repeated my experiment with a table control with the same erronous results.
<sigh>
When exporting to PDF, does SRS ignore the "KeepTogether" attribute instead treating is at "True"?
Thanks Chris
> We also take issue with how the textbox control handles page splits. We > called into MS Support and ended up writing some text parsing logic. It's [quoted text clipped - 422 lines] >> Thanks, >> Chris Wei Lu [MSFT] - 23 Oct 2006 07:34 GMT Hello Chris,
I would like to know how you design the report. On my side, I could not reproduce this issue.
Would you please post the report rdl file here?
Sincerely,
Wei Lu
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues where an initial response from the community or a Microsoft Support Engineer within 1 business day is acceptable. Please note that each follow up response may take approximately 2 business days as the support professional working with you may need further investigation to reach the most efficient resolution. The offering is not appropriate for situations that require urgent, real-time or phone-based interactions or complex project analysis and dump analysis issues. Issues of this nature are best handled working with a dedicated Microsoft Support Engineer by contacting Microsoft Customer Support Services (CSS) at http://msdn.microsoft.com/subscriptions/support/default.aspx.
================================================== (This posting is provided "AS IS", with no warranties, and confers no rights.)
Wei Lu [MSFT] - 24 Oct 2006 09:17 GMT Hello Chris,
I have tested the report.
When I export it to the PDF, I see a blank page in the first page. Also, if I try to print it in the printer, the print preview show the same behavior.
I think this is the pagination of the print setting. Is this the same behavior you met?
Sincerely,
Wei Lu Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so that others may learn and benefit from your issue.
==================================================
 Signature This posting is provided "AS IS" with no warranties, and confers no rights.
Chris Walls - 24 Oct 2006 13:46 GMT Yes, this is the same behavior that I'm seeing. I'm not sure what you mean when you refer to "the print setting". Does that mean we can change this behavior?
Thanks, Chris
> Hello Chris, > [quoted text clipped - 21 lines] > This posting is provided "AS IS" with no warranties, and confers no > rights. Wei Lu [MSFT] - 25 Oct 2006 04:25 GMT Hello Chris,
Well, the pagination in PDF output is determined by the page width and height for the report, plus margins.
You could specify the PageHeight setting in the device information setting.
For example, I use this url to render your report to the PDF format and it results that the pdf file have only one page:
http://localhost/ReportServer?%2fReportTest%2fTest&rs:Command=Render&rs:Form at=PDF&rc:PageHeight=12in
Hope this will be helpful for you.
Sincerely,
Wei Lu Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so that others may learn and benefit from your issue.
==================================================
 Signature This posting is provided "AS IS" with no warranties, and confers no rights.
Chris Walls - 25 Oct 2006 14:49 GMT Wei,
I don't get it. Why should I have to change the PageHeight? I feel it is counter-intuitive, and to be honest a bit strange, to set the page height to 12 inches when in fact we'll be printing on standard portrait 11 x 8.5 inch paper.
Are we saying that this behavior we're seeing with the textbox is correct and by design? Or is this suggestion just a work-around?
I appreciate your help with this.
Thanks, Chris
> Hello Chris, > [quoted text clipped - 25 lines] > This posting is provided "AS IS" with no warranties, and confers no > rights. Wei Lu [MSFT] - 26 Oct 2006 09:30 GMT Hello Chris,
The fact is, the textbox which contained over 32 lines is height over 5in in the layout. And since it located at 0.5in 4in, and the report margin is TOP 1in and Bottom 1 in. So all these added is over 11in in height.
So if you try to reduce the margin to make less than 11in, you could print the textbox in the first page.
I tested on my side. The location of the textbox is 0.5in and 4in, the textbox height is 5.375in and the report margin is TOP 0in and Bottom 0in. Then i get the text show in the first page when I try to print to PDF.
Hope this will be helpful.
Sincerely,
Wei Lu
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues where an initial response from the community or a Microsoft Support Engineer within 1 business day is acceptable. Please note that each follow up response may take approximately 2 business days as the support professional working with you may need further investigation to reach the most efficient resolution. The offering is not appropriate for situations that require urgent, real-time or phone-based interactions or complex project analysis and dump analysis issues. Issues of this nature are best handled working with a dedicated Microsoft Support Engineer by contacting Microsoft Customer Support Services (CSS) at http://msdn.microsoft.com/subscriptions/support/default.aspx.
================================================== (This posting is provided "AS IS", with no warranties, and confers no rights.)
Chris Walls - 26 Oct 2006 12:59 GMT Wei,
It sounds like you are saying the textbox behaves in a similar fashion to MS Word's paragraph option "Keep Together" and there is no way to override this behavior.
Perhaps we could suggest to MS to make this optional for SRS in the future.
Thanks for your help.
- Chris
> Hello Chris, > [quoted text clipped - 38 lines] > (This posting is provided "AS IS", with no warranties, and confers no > rights.) Wei Lu [MSFT] - 27 Oct 2006 10:20 GMT Hello Chris,
Since the textbox control does not have the "Keep Together" property, you could not configure it.
The Textbox will keep all the content together. You could send your feedback directly to the product team:
http://connect.microsoft.com/sqlserver
Thank you for your response.
Sincerely,
Wei Lu Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so that others may learn and benefit from your issue.
==================================================
 Signature This posting is provided "AS IS" with no warranties, and confers no rights.
Wei Lu [MSFT] - 31 Oct 2006 10:45 GMT Hi ,
How is everything going? Please feel free to let me know if you need any assistance.
Sincerely,
Wei Lu Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so that others may learn and benefit from your issue.
==================================================
 Signature This posting is provided "AS IS" with no warranties, and confers no rights.
|
|
|