Incorrect display of TEXT in SVG - html

The code that generates SVG:
"<text x=\"" + (Width / 2) + "\" y=\"18\" width=\"30\" text-anchor=\"middle\" font-weight=\"Bold\" font-family=\"Simplex\" font-size=\"7\">" + "123" + "</text>"
The code is looped so it displays repeatedly
What's wrong with this text?
Conclusions:
centers the first digit
other elements start at the beginning of the element
When I remove the text-anchor, it changes a little but it still displays incorrectly

The problem is probably division by 2 (Width / 2)
You get a floating point value, which means that the separator is , instead of . in String Value
Use:
(Width / 2).ToString("0.00", CultureInfo.InvariantCulture)

Related

Using matchbox to insert PDF in text flow Yes or No?

I am using matchbox to insert images into text_flow which is working nicely, I need to do the same with small PDF charts - before I go down this path just wondering if its even possible ....Yes / No ?
sure, instead of fitting the image you just have to use the PDF page afterwards. So when you go the way of the following PDFlib Cookbook sample http://www.pdflib.com/pdflib-cookbook/text-output/wrap-text-around-images/ (case 4) but just place a PDI page instead of the fit_image():
x1 = p.info_matchbox(matchboxnames[m][0], i, "x1");
y1 = p.info_matchbox(matchboxnames[m][0], i, "y1");
width = p.info_matchbox(matchboxnames[m][0], i, "width");
height = p.info_matchbox(matchboxnames[m][0], i, "height");
p.fit_pdi_page(page, x1, y1,
"boxsize {" + width + " " + height +
"} fitmethod meet position=center");

Get the text between two characters in sql server

i have tried using charindex function but unable to get it.
Text is :- Offshore/BLR/IN
i want only BLR" out of this.
please help.
Presuming that what you are actually asking is how to get the text between the forward-slashes, you could do this easily using CHARINDEX.
See the following example:
DECLARE #Text varchar(100)
SET #Text = '- Offshore/BLR/IN'
PRINT CHARINDEX('/', #Text)
PRINT CHARINDEX('/', #Text, CHARINDEX('/', #Text) + 1)
This will output 11 and 15, respectively, which shows the position of the first and second forward-slash.
The second position is found by searching the text that occurs after the first position.
Following this it's just a simply case of using SUBSTRING to extract the text from the middle of the slashes:
PRINT SUBSTRING(#text, CHARINDEX('/', #text) + 1, CHARINDEX('/', #text, CHARINDEX('/', #text)+ 1) - CHARINDEX('/', #text) - 1)
This essentially gets the text between the first slash (+1 position to exclude the slash), to the position of the second slash minus the position of the first slash minus 1 (to remove the first slash).
This is basically:
PRINT SUBSTRING(#text, 11 + 1, 15 - 11 - 1)
Note that is the text does not contain both slashes then this code will fail. It contains no bounds or error checking at all, and you should look to add this.

Is it possible to apply different colours to different parts of an Indic character?

Being inspired by Is it possible to apply CSS to half of a character? I was wondering if something similar could be done with Indic text? As an example, in Sinhala ක + ා = කා (consonant + vowel). Is it possible to render the vowel stroke as a different colour from the base consonant? Other combinations:
ක + ෙ = කෙ
ක + ු = කු
ක + ො = කො
ක + ් = ක්
ම + ් = ම්
ම + ු = මු
ද + ා = දා
ක + ්‍ර = ක්‍ර
ර්‍ + ක = ර්‍ක
ක + ්‍ය = ක්‍ය
ර්‍ + ක + ්‍ර + ො = ර්‍ක්‍රො
I'm looking for an effect similar to this:
Thanks in advance for your awesome answers!
I've had a play with the code from the previous question and come up with this:
http://experimental.haujuseiit.com/vowelstroke.html
If you go to the link you'll see that some combinations don't work but most of them do. The other issue is when the vowel stroke is completely or partially before the consonant. I've had to set explicit widths for "e" (yellow) and "ee" (dark green) which will probably break with different fonts.
I'll post the source code when I've automated the solution.
Improvements anyone?
As far as I know it is not possible to apply a css style to half a character, but I bet you could fake it using two z-indexed graphics, or even glyphs, of differing color. Using one to mask the other.
That would work, but would be a huge amount of work.

Can I get access to the series legend text from the tooltip expression?

When setting a tooltip expression for the chart series, is it possible to access the same series' legend text? What would be the syntax? I just want to aviod having to type the same literal in two places. I.e. instead of
=Fields!Metric.Value + ", Literal : " + FormatNumber(Fields!Data.Value, 2)
I would like to use whatever syntax for the Series/Legend Text:
=Fields!Metric.Value + Series.LegendText + FormatNumber(Fields!Data.Value, 2)

Header using Itext

ColumnText.showTextAligned(cb, Element.ALIGN_CENTER, new Phrase(headerContent,headerFont) ,document.right() - 300, document.top() + 5, 0);
I have this line of code.For A4 papersize I get the header at the center of the page but for A3,A2,A1 I get it to the left of the page.What should I do so that I get it to the center of the page for all papersize(A4,A3,A2,A1).
You should use (document.left() + document.right()) / 2 for the x value.
As for the y value, you should use document.top() - (headerFont.getSize() * 1.5f). As far as I know document.top() + 5 results in adding text in the invisible area above the actual page.