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
[quoted text, click to view] "Chris Walls" <chwalls2@community.nospam> wrote in message
news:eqImSaQ9GHA.3736@TK2MSFTNGP02.phx.gbl...
> 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
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
[quoted text, click to view] "Steve MunLeeuw" <smunson@clearwire.net> wrote in message
news:uCKN3$S9GHA.4224@TK2MSFTNGP02.phx.gbl...
> 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);
>
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.)
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.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
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
[quoted text, click to view] "Wei Lu [MSFT]" <weilu@online.microsoft.com> wrote in message
news:bJavwT09GHA.3476@TK2MSFTNGXA01.phx.gbl...
> 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.
>
> ==================================================
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>
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.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
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
[quoted text, click to view] "Wei Lu [MSFT]" <weilu@online.microsoft.com> wrote in message
news:iFu2WV%239GHA.4468@TK2MSFTNGXA01.phx.gbl...
> 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.
>
> ==================================================
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>
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.)
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
[quoted text, click to view] "Wei Lu [MSFT]" <weilu@online.microsoft.com> wrote in message
news:MN1XIkN%23GHA.4992@TK2MSFTNGXA01.phx.gbl...
> 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.)
>
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.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
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.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Don't see what you're looking for? Try a search.