Reputation: 21
I'm making a symbol generator in C# using this SVG library. As I try to include text like this:
private void buttonDraw_Click(object sender, EventArgs e)
{
document(); //function to prepare the document and canvas.
SvgUnitCollection pin1 = new SvgUnitCollection()
{0,50};
SvgText hello = new SvgText();
hello.Text = "Hello World";
hello.X = pin1;
hello.Y = pin1;
SvgGroup.myGroup.Children.Add(hello);// Adding elements to the canvas.
draw(); //Function to draw into an image box.
}
I get this:
Any help to correct this issue and explanation in why does this happen, is very appreciated.Thanks in advance.
Upvotes: 1
Views: 538
Reputation: 21
Thank you guys. After all, the problem was that I put two svg units in the collection and I needed two separate collections, like this:
SvgUnitCollection textX = new SvgUnitCollection()
{ 60};
SvgUnitCollection textY = new SvgUnitCollection()
{ 85};
SvgUnitCollection center= new SvgUnitCollection()
{ 14};
SvgText hello= new SvgText();
hello.Text = "Hello world"
hello.X = textX;
hello.Y = textY;
hello.Dx = center;//align the text to your canvas as you want.
hello.FontSize = 27;
It seems kind of redundant for me but it works with this library. Thank you again. (Not sarcasm, just not native english speaker)
Upvotes: 1