04-24-2014, 01:24 PM
Uh, now I finally understand the problem.
I see now that ViewerSvg can show different xaml because it can use some internal ways to get read object as geometry.
I will update ReaderSvg in such a way that it will be also possible to read svg file as geometry without getting the Transformation or additional RectangleGeometry to ensure correct size.
What is more, I will also add an option to optimize groups - so you will not get Canvases or DrawingGroup that contain only another Canvas or DrawingGroup.
pranav, when I will prepare the fix for that I will prepare a pre-release version for you.
Until than you can use the following workaround (it is not nice - it deletes the transformation before calling GetXaml method).
var readerSvg = new Ab2d.ReaderSvg();
readerSvg.AutoSize = true;
var readImage = readerSvg.ReadGeometry(svgFileName);
if (readImage != null)
{
try
{
((DrawingGroup) ((DrawingGroup) ((DrawingImage) readImage.Source).Drawing).Children[0]).Transform = null;
}
catch
{
// just in case
}
}
string xaml = readerSvg.GetXaml();
I see now that ViewerSvg can show different xaml because it can use some internal ways to get read object as geometry.
I will update ReaderSvg in such a way that it will be also possible to read svg file as geometry without getting the Transformation or additional RectangleGeometry to ensure correct size.
What is more, I will also add an option to optimize groups - so you will not get Canvases or DrawingGroup that contain only another Canvas or DrawingGroup.
pranav, when I will prepare the fix for that I will prepare a pre-release version for you.
Until than you can use the following workaround (it is not nice - it deletes the transformation before calling GetXaml method).
var readerSvg = new Ab2d.ReaderSvg();
readerSvg.AutoSize = true;
var readImage = readerSvg.ReadGeometry(svgFileName);
if (readImage != null)
{
try
{
((DrawingGroup) ((DrawingGroup) ((DrawingImage) readImage.Source).Drawing).Children[0]).Transform = null;
}
catch
{
// just in case
}
}
string xaml = readerSvg.GetXaml();
Andrej Benedik

