How can I preserve leading white space in PDF export of reporting services - reporting-services

I have some leagacy reporting data which is accessed from SSRS via an xml web service data source. The service returns one big field containing formatted plain text.
I've been able to preserve white space in the output by replacing space chars with a non-breaking space, however, when exporting to PDF leading white space is not preserved on lines that do not begin with a visible character. So a report that should render like this:
Report Title
Name Sales
Bob 100.00
Wendy 199.50
Is rendered like this:
Report Title (leading white space stripped on this line)
Name Sales (intra-line white space is preserved)
Bob 100.00
Wendy 199.50
I've not been able to find any solution other than prefixing each line with a character which I really don't want to do.
Using SQL 2005 SP3

I googled and googled the answer to this question. Many answers included changing spaces to Chr(20) or Chr(160). I found a simple solution that seems to work.
If your leading spaces come from a tab stop replace "/t" with actual spaces, 5 or so
string newString = oldString.Replace("/t"," ")
In the expression field for the textbox I found that simply adding a null "Chr(0)" at the beginning of the string preserves the leading spaces.
Example:
=Chr(0) & "My Text"

Have you tried non-breaking spaces of the ASCII variety?
=Replace(Fields!Report.Value, " ", chr(160))
I use chr(160) to keep phone numbers together (12 345 6789). In your case you may want to only replace leading spaces.

You can use padding property of the textbox containing the text. Padding on the left can be increased to add space that does not get stripped on output.

I have used this work around:
In the Textbox properties select the alignment tab.
In the Padding option section edit the right or left padding(wherever you need to add space).
If you need to conditionally indent the text you can use the expression as well.

Related

How to limit simple form input to 50 characters

Is it possible to limit a simple form input to only 50 characters without javascript?
I have used the max_length attribute, however this includes blank spaces which is not what i want.
I've attempted to use pattern (as suggested on another post), but i can't seem to get that to work either.
Thanks
I don't know why you don't want it to include blanks.
Usually I use max_length including blanks and leave it to the user to trim their excess whitespace. I'm not disagreeing, I honestly don't know what your requirement is.
If you want to allow leading and trailing whitespace, but are willing to leave it to the user to replace excess whitespace within the text to one whitespace character then this is the pattern you want:
<input pattern="^\s*.{0,50}\s*$">
Sometimes for multiline regular expressions, \A is used instead of ^ and \z is used instead of $, but I'm not sure HTML supports that in their regular expressions.

Replace text next to static text google script

I would like to replace the text in a google doc. At the moment I have place markers as follows
Invoice ##invoiceNumber##
I replace the invoice number with
body.replaceText('##invoiceNumber##',invoiceNumber);
Which is fine but I can only run the script once as obviously ##invoiceNumber## is no longer in the document. I was thinking I could replace the text after Invoice as this will stay the same, appendParagraph looks like it might to the trick but I can't figure it out. I think something like body.appendParagraph("Invoice") would select the area? Not sure how to append to this after that.
You could try something like this I think:
body.replaceText('InvoiceNumber \\w{1,9} ','InvoiceNumber ' + invoicenumber);
I don't know how big your invoice numbers are but that will except from 1 to 9 word characters preceeded by a space and followed by a space. That pattern might have to be modified depending upon your textual needs.
Word Characters [A-Za-z0-9_]
If your invoice numbers are unique enough perhaps you could just replace them.
Reference
Regular Expression Syntax
Note: the regex pattern is passed as a string rather than a regular expression

Mysql multiple replace query leaving unwanted leading white space. How to remove it?

People,
Currently i have a string mysql field Class on a table.
It´s a code plus a description. I need to extract the description only (without a whitespace in the begining of the string).
The rule of formation of this field data follows:
N.N Description(without any digit or dots) or N.N. Description (without any digit or dots)
Where N is a number between 1 and 10.
I´ve tried this multiple replace but it remains two cases with one leading white space that i could not remove:
' Suspension'
and
' Reduction'
My multiplce replace is:
REPLACE(REPLACE(REPLACE(TRIM(BOTH ' ' FROM (REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(class,'.',''),'1',''),'0',''),'2',''),'3',''),'4',''),'5',''),'6',''),'7',''),'8',''),'9',''))),'\r',''),'\t',''),'\n','')
What this leading white space could be so i can replace it? What could be missing?
Or anyone have a better idea how to solve this?
Probably you are replacing with white space and this the modified string ends up with that. Why can't you use TRIM() function on your final replaced string to get rid of those leading spaces.

difference between " " and nbsp; or " "

Hello I am trying to compile an EPUB v2.0 with html code extracted from Indesign. I have noticed there are a lot of "special characters" either at the beginning of a paragraph or at the end. For example
<p class="text_indent0px font_size0_8em line_height1_325 margin_bottom1px margin_left0px margin_right0px sans_serif floatleft">E<span class="small_caps">VELYNE</span> </p>
What is this
and can I either get rid of it or replace it with a "nbsp;"?
&#9
Is the ascii code for tabs. So I guess the paragraphs were indented with tabs.
If you want to replace them with then use 4 of them
That would be a horizontal tab (i.e. the same as using the tab key).
If you want to replace it, I would suggest doing a find/replace using an ePub editor like Sigil (http://sigil-ebook.com/).
represents the horizontal tab
Similarly represent space.
To replace you have to use
In the HTML encoding &#{number}, {number} is the ascii code. Therefore, is a tab which typically condenses down to one space in HTML, unless you use CSS (or the <pre> tag) to treat it as pre formatted text.
Therefore, it's not safe to replace it with a non-breaking or a regular space unless you can guarantee that it's not being displayed as a tab anywhere.
div:first-child {
white-space: pre;
}
<div> Test</div>
<div> Test</div>
<pre> Test</pre>
See https://developer.mozilla.org/en-US/docs/Web/CSS/white-space and http://ascii.cl/
is the entity used to represent a non-breaking space
decimal char code of space what we enter using keyboard spacebar
decimal char code of horizontal tab
and both represent space but is non-breaking means multiple sequential occurrence will not be collapsed into one where as for the same case, ` will collapse to one space
= approx. 4 spaces and approx. 8 spaces
There are four types of character reference scheme used.
Using decimal character codes (regex-pattern: &#[0-9]+;),
Using hexadecimal character codes (regex-pattern: &#x[a-f0-9]+;),
Using named character codes (regex-pattern: &[a-z]+;),
Using the actual characters (regex-pattern: .).
Al these conversions are rendered same way. But, the coding style is different. For example, if you need to display a latin small letter E with diaeresis then you could use any of the below convention:
ë (decimal notation),
ë (hexadecimal notation),
ë (html notation),
ë (actual character),
Likewise, as you said, what should be used (a) (decimal notation) or (b) (html notation) or (c) (decimal notation).
So, from the above analogy, it can be said that the (a), (b) and (c) are three different kind of notation of three different characters.
And, this is for your information that, (a) is a Horizontal Tab, the (b) one is the non-breaking space which is actually   in decimal notation and the (c) is the decimal notation for normal space character.
Now, technically space at the end of the paragraph, is nothing but meaningless. Better, you could discard those all. And if you still need to use space inside <pre> elements, not in <p> or <div>.
Hope this helps...

Remove first line from HTML Markup Field using RegEx

I have a single text field that contains HTML markup. The system that generates this field content always seems to generate a first line with a non-visible carriage return value in it and I can't seem to prevent if from doing so.
Does anyone know of a way (perhaps using a Regular Expression), to remove that first line from this text field?
I'd prefer to leave all other instances of the carriage return values in the field as is, so if it's a RegEx statement that will just remove the first line of a text field, that would work for me.
Any suggestions most welcomed.
Cheers,
Wayne
Usually the trim (often removes whitespaces, CR ) method is used for this in many programming languages. You did not state in what language you will be doing this...