Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SVG elements are missing interpretation of dx and dy values #1271

Open
dennemark opened this issue Apr 28, 2021 · 0 comments
Open

SVG elements are missing interpretation of dx and dy values #1271

dennemark opened this issue Apr 28, 2021 · 0 comments

Comments

@dennemark
Copy link

dennemark commented Apr 28, 2021

Describe the bug
As described in this issue: #1234 Text, T-Span and Rect elements (maybe others, too) are not considering dx and dy values for relative positioning.

To Reproduce
Take this svg i.e.
Each color has a different relative positioning to the parent.

  • If the child has a x or y property, it will favour it over the parent property and position itself absolute. In this case dx and dy will be ignore, too.
  • If the x or y porperty is missing it will be positioned relative to parent.
  • If dx or dy exist, they will be added to the parent
<svg width="500" height="500">
    <text x="10" y="10" width="90" height="60">
		<tspan dx="10" dy="10" width="20" height="10" fill="blue">text</tspan>
    </text>
    <text x="10" y="10" width="90" height="60" >
    	<tspan x="10" dy="10" fill="red">text</tspan>
    </text>
  <text x="10" y="10" width="90" height="60" fill="green">
 	 <tspan x="10" y="10">text</tspan>
   </text>
</svg>

image

The result of react-pdf has all text elements at position x=10 and y=10:
image

The issue seems only relevant for conversion from existing svgs to react-pdf svg. The above mentioned issue has examples on how to convert from SVG to react-pdf SVG with consideration of parent position.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants