The problem is illustrated within attached code.
var diagram = new AtsPrintDiagram()
{
// Width: 1056, Height: 1600.
Bounds = atsDiagramControl.Bounds,
};
var textItemLocation = new Vector2(550, 800);
var textItemGeometry = new TextGeometry(textItemLocation)
{
Text = "Random text",
};
textItemGeometry.SetHeight(100);
textItemGeometry.SetWidth(400);
textItemGeometry.FontStyle.FontSize = 48;
// Text item will override Draw method.
// It will call diagram.DrawStyledText method.
// ParentDiagram.DrawStyledText(graphics, coloredText, textAttributes, bounds);
var textItem = new AtsTextDiagramItem(diagram, textItemGeometry)
{
// Here it's will work as expected, because it will be drawn through diagram.
// RenderTransform = Transform.Identity,
RotationAngle = 25,
};
diagram.Items.Add(textItem);
// Also, we are always set SvgText.DrawAsPath property to 'false'.
var svgNodeWithText = new ParentSvgNode(diagram);
diagram.Items.Add(svgNodeWithText);
var svgExporter = new SvgExporter()
{
// In this test case it doesn't matter, but in the real cases...
// Text SvgNode drawing incorrect with SetClipPaths = true, if its 'false' it works as expected.
// But our 'Mask' implementation doesn't work without SetClipPaths = true property.
SetClipPaths = true,
};
var svgStream = new MemoryStream();
svgExporter.Export(diagram, svgStream);
class ParentSvgNode : SvgNode
{
public ParentSvgNode(AtsDiagram diagram)
{
Bounds = new System.Windows.Rect(0, 0, 700, 500);
Transparent = true;
MindFusion.Svg.SvgText.DrawAsPath = false;
var exporter = new SvgExporter();
var ms = new MemoryStream();
var innerDiagram = new AtsDiagram()
{
Bounds = Bounds,
};
// Just a location where the item was dropped onto page.
var textItemLocation = new Vector2(500, 400);
var textItemGeometry = new TextGeometry(textItemLocation)
{
Text = "Exported text as svg",
};
textItemGeometry.SetHeight(400);
textItemGeometry.SetWidth(400);
textItemGeometry.FontStyle.FontSize = 36;
// Text item will override Draw method.
// It will call diagram.DrawStyledText method.
// ParentDiagram.DrawStyledText(graphics, coloredText, textAttributes, bounds);
var textItem = new AtsTextDiagramItem(diagram, textItemGeometry)
{
// When we apply RenderTransform or Rotation Angle its cut off.
// Because it's nested element inside SvgNode that exported by exporter and loaded by node.
// RenderTransform = Transform.Identity,
// RotationAngle = 25,
};
innerDiagram.Items.Add(textItem);
exporter.Export(innerDiagram, ms);
this.LoadSvg(ms);
}
}
AtsTextDiagramItem internally change RenderTransform and RotationAngle properties dependent on our setups, it works as expected when we just add it to the Diagram.Items collection, but when we export this element as Svg (by SvgExporter) and then load content by SvgNode (and append node to the Diagram.Items) collection - it's cut off. As i see, its related with the RenderTransform and RotationAngle.
Attachment 1: ParentSvgNode (in constructor) textItem.RotationAngle is not set (it's 0), i'm not sure maybe RenderTransform is a little changed. It's drawn with a little cutting from top.
Attachment 2: ParentSvgNode (in constructor) textItem.RotationAngle = 25, an element just cut off from the diagram.
Related topic with the mask:
https://mindfusion.eu/Forum/YaBB.pl?num=1675858956/0#0If we set SetClipPaths to false it will work as expected, also with the SvgNode.