diff --git a/itext.tests/itext.svg.tests/itext/svg/renderers/impl/TSpanNodeRendererIntegrationTest.cs b/itext.tests/itext.svg.tests/itext/svg/renderers/impl/TSpanNodeRendererIntegrationTest.cs index d3382693c2..91eb1c836c 100644 --- a/itext.tests/itext.svg.tests/itext/svg/renderers/impl/TSpanNodeRendererIntegrationTest.cs +++ b/itext.tests/itext.svg.tests/itext/svg/renderers/impl/TSpanNodeRendererIntegrationTest.cs @@ -179,6 +179,12 @@ public virtual void TSpanTextAnchorFunctionalTest() { ConvertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "textspan-textAnchor"); } + //Text-anchor test using transform attribute for X position + [NUnit.Framework.Test] + public virtual void TSpanTextAnchorTransformFunctionalTest() { + ConvertAndCompare(SOURCE_FOLDER, DESTINATION_FOLDER, "textspan-textAnchor-transform"); + } + [NUnit.Framework.Test] //TODO: update after DEVSIX-2507 and DEVSIX-3005 fix [LogMessage(iText.StyledXmlParser.Logs.StyledXmlParserLogMessageConstant.UNKNOWN_ABSOLUTE_METRIC_LENGTH_PARSED diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/TSpanNodeRendererIntegrationTest/cmp_textspan-textAnchor-transform.pdf b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/TSpanNodeRendererIntegrationTest/cmp_textspan-textAnchor-transform.pdf new file mode 100644 index 0000000000..8f9b14570b Binary files /dev/null and b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/TSpanNodeRendererIntegrationTest/cmp_textspan-textAnchor-transform.pdf differ diff --git a/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/TSpanNodeRendererIntegrationTest/textspan-textAnchor-transform.svg b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/TSpanNodeRendererIntegrationTest/textspan-textAnchor-transform.svg new file mode 100644 index 0000000000..31dcbc59f5 --- /dev/null +++ b/itext.tests/itext.svg.tests/resources/itext/svg/renderers/impl/TSpanNodeRendererIntegrationTest/textspan-textAnchor-transform.svg @@ -0,0 +1,144 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + no text anchor + + start text anchor + + middle text anchor + + end text anchor + + + + + + no text anchor + + start text anchor + + middle text anchor + + end text anchor + + + + + + no text anchor + + start text anchor + + middle text anchor + + end text anchor + + + + + + no text anchor + + start text anchor + + middle text anchor + + end text anchor + + + diff --git a/itext/itext.svg/itext/svg/renderers/impl/TextSvgBranchRenderer.cs b/itext/itext.svg/itext/svg/renderers/impl/TextSvgBranchRenderer.cs index 920d62b0d1..7e58ec672c 100644 --- a/itext/itext.svg/itext/svg/renderers/impl/TextSvgBranchRenderer.cs +++ b/itext/itext.svg/itext/svg/renderers/impl/TextSvgBranchRenderer.cs @@ -411,15 +411,11 @@ internal virtual float GetTextAnchorAlignmentCorrection(float childContentLength String textAnchorValue = this.GetAttribute(SvgConstants.Attributes.TEXT_ANCHOR); // Middle if (SvgConstants.Values.TEXT_ANCHOR_MIDDLE.Equals(textAnchorValue)) { - if (xPos != null && xPos.Length > 0) { - textAnchorXCorrection -= childContentLength / 2; - } + textAnchorXCorrection -= childContentLength / 2; } // End if (SvgConstants.Values.TEXT_ANCHOR_END.Equals(textAnchorValue)) { - if (xPos != null && xPos.Length > 0) { - textAnchorXCorrection -= childContentLength; - } + textAnchorXCorrection -= childContentLength; } } return textAnchorXCorrection;