This is what we can test without having your TextGeometry / attachedObjects definitions:
// TextNode.cs
public override void Draw(DrawingContext graphics, MindFusion.Diagramming.Wpf.RenderOptions options)
{
var bounds = GetBounds();
var center = new Vector(bounds.Location.X, bounds.Location.Y) - new Vector(Bounds.TopLeft.X, Bounds.TopLeft.Y);
bounds.Location = new Point(center.X, center.Y);
//var textAttributes = DiagramTextUtils.GetTextAttributesFromDomainEntity(TextGeometry.FontStyle);
//var translationResult = translationService.TranslateVariables(TextGeometry);
//attachedObjects = translationResult.AttachedObjects;
//var coloredText = DiagramTextUtils.ColorizeText(translationResult.TranslatedText, TextGeometry.FontStyle.FontColor);
Parent.DrawStyledText(graphics, Text, this, bounds);
}
...
// Window.cs
void TestSvgExIm()
{
var node1 = diagram.Factory.CreateShapeNode(
0, 0, 100, 100, Shapes.Ellipse);
node1.Brush = Brushes.Transparent;
var node2 = diagram.Factory.CreateShapeNode(
0, 100, 100, 100, Shapes.RoundRect);
node2.Brush = Brushes.Transparent;
diagram.ResizeToFitItems(0);
new SvgExporter().Export(diagram, "test1.svg");
var text = new TextNode();
text.Bounds = new Rect(10, 30, 50, 20);
text.Text = "test";
diagram.Nodes.Add(text);
new SvgExporter().Export(diagram, "test2.svg");
var svg1 = new SvgContent();
svg1.Parse("test1.svg");
var svgNode1 = diagram.Factory.CreateSvgNode(
200, 0, 100, 200, svg1);
svgNode1.Shape = Shapes.Rectangle;
svgNode1.Transparent = true;
var svg2 = new SvgContent();
svg2.Parse("test2.svg");
var svgNode2 = diagram.Factory.CreateSvgNode(
330, 0, 100, 200, svg2);
svgNode2.Shape = Shapes.Rectangle;
svgNode2.Transparent = true;
diagram.ResizeToFitItems(50);
}
and it's showing no difference in SVG bounds. Note that SVG viewport size is set to diagram.Bounds and not to bounding box of just graphics elements, so our best guess is the diagram is larger when you add the TextNode to it. Either the text node itself is larger than the surrounding graphics nodes from your screenshots (which might not be obvious if only drawing text in its center), or the 'attachedObjects' thing from your Draw method adds some invisible nodes that make the diagram larger.
Regards,
Slavcho
Mindfusion