Report Viewer removes leading whitespace from Placeholder content when HTML format is enabled - by Carl Daniel

Status : 

  Not Reproducible<br /><br />
		The product team could not reproduce this item with the description and steps provided.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Sign in
to vote
ID 781925 Comments
Status Closed Workarounds
Type Bug Repros 0
Opened 3/22/2013 7:00:05 AM
Access Restriction Public


A placeholder in SSRS removes all leading whitespace from the content if HTML formatting is enabled for the placeholder.  This is correct and valid for some whitespace characters, but others, such as U+00A0 (non-breaking space) should be preseved. 

Note that this is NOT simply the normal HTML rendering behavior of collapsing reduntant whitespace - the placeholder control is actively removing leading whitespace, including whitespace characters like U+00A0 (NBSP) that really should be preserved.

There are additional oddities when certain Unicode whitespace characters are added to the start of the line:
adding a leading U+200C (zero-width non-joiner):
 •The winforms Report Viewer renders the report perfectly
•The webforms Report Viewer renders the ZWNJ as a vertical bar | character
•Export to Word looks perfect
•Export to Excel looks perfect
•Export to PDF has spacing issues all over the page (it's a mess)
•Export to MHTML renders the ZWNJ as a vertical bar | character.

Using U+2060 (Word Joiner) is fun too:
 •The winforms Report Viewer renders WJ as a small box
•The webforms Report Viewer renders the report perfectly.
•Export to Word shows the WJ as a small box
•Export to Excel shows the WJ as a small box
•Export to PDF shows the WJ as a small box, but the spacing issues are resolved
•Export to MHTML looks perfect.

Sign in to post a comment.
Posted by Matt [MSFT] on 12/20/2013 at 1:38 PM
Great! I'm glad my fix addresses your issue!!

Matt Jones
SSRS Tiger Dev
Posted by Carl Daniel on 12/19/2013 at 2:08 PM
SQL 2012 SP1 does indeed appear to render this correctly without any workaround.
Posted by Matt [MSFT] on 11/7/2013 at 2:10 PM
Thanks again for your feedback. Are you able to test your example on SQL Server 2012 Service Pack 1 or later? I want to make sure my fix addresses your issue.

Matt Jones
SSRS Tiger Dev
Posted by Carl Daniel on 10/16/2013 at 10:22 AM
In the example that I attached, inserting <span/> before the text has no effect. Inserting <br/><span/> before the text does indeed preserve the leading whitespace - but it also inserts a line-break (no surprise there).
Posted by Carl Daniel on 10/15/2013 at 10:59 PM
Perhaps I'm missing something, but neither my example nor my actual use case contains a <br/> - where are you proposing I insert a <span/>?
Posted by Matt [MSFT] on 10/15/2013 at 1:32 PM
Thank you for the feedback. I have fixed this issue in SQL Server 2012 Service Pack 1. For previous version of SQL Server, a workaround is available.

Insert a <span /> after the <BR /> and before the text. This would be a more generalized workaround that does not change the meaning of the existing html. You could add more logic to the following example, to not insert a span if it is not really necessary.

Function InsertSpansAfterBRs(html As String) as String
Dim i As Integer = 0
'This can be changed to support other tags, as well,
'such as <p>, <li> and <div>, using IndexOfAny.
while (i < html.Length AndAlso
    (i = html.IndexOf("<br", i, StringComparison.OrdinalIgnoreCase)) <> -1)        
    For i = i + 3 To html.Length - 1
     If (html(i) = ">"c) Then
        html = html.Insert(i+1, "<span />")
        i = i + 9
        Exit For
     End If
End While
Return html
End Function

Matt Jones
SSRS Tiger Dev