OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

pyvista export does not preserve multiline texts

  • Thread starter Thread starter PiWi
  • Start date Start date
P

PiWi

Guest
I am rendering a mesh with Pyvista (version 0.43.5) and I have a problem with multiline texts at export.

In the interactive window and when I take a screenshot, a multiline title (or any other multiline text) is rendered well. But when I export to svg, the multiline is gone:

interactive window and screenshot (OK)export to svg (via plotter.save_graphic) (KO)
ORCmW218.png
fzhYgTJ6.png

Here is the code I use:

Code:
import pyvista as pv
mesh = pv.Cylinder()
pl = pv.Plotter(off_screen=True)
pl.add_mesh(mesh, label="cyl")
pl.add_title("first line\nsecond line\nthird one")
pl.save_graphic('multiline_title_test.svg')  # 'svg', 'eps', 'ps', 'pdf', 'tex'
pl.show(screenshot='multiline_title_test.png')
pl.close()

Question: is there a way to preserve multiline at svg export? (using pyvista or maybe vtk)

Edit 1: as I advance in understanding of the problem (but not of the solution so far):

The generated svg page includes for text:

Code:
<text fill="#000000" x="512" y="-5" font-size="45" text-anchor="middle" dy="45" font-family="Helvetica">
first line
second line
third one</text>

From this link How to display multiple lines of text in SVG?, I understand it should include some 'tspan' with x and dy properties. Is this the only way?
<p>I am rendering a mesh with Pyvista (version 0.43.5) and I have a problem with multiline texts at export.</p>
<p>In the interactive window and when I take a screenshot, a multiline title (or any other multiline text) is rendered well. But when I export to svg, the multiline is gone:</p>
<div class="s-table-container"><table class="s-table">
<thead>
<tr>
<th>interactive window and screenshot (OK)</th>
<th>export to svg (via plotter.save_graphic) (KO)</th>
</tr>
</thead>
<tbody>
<tr>
<td><img src="https://i.sstatic.net/ORCmW218.png" height="300"></td>
<td><img src="https://i.sstatic.net/fzhYgTJ6.png" height="300"></td>
</tr>
</tbody>
</table></div>
<p>Here is the code I use:</p>
<pre><code>import pyvista as pv
mesh = pv.Cylinder()
pl = pv.Plotter(off_screen=True)
pl.add_mesh(mesh, label="cyl")
pl.add_title("first line\nsecond line\nthird one")
pl.save_graphic('multiline_title_test.svg') # 'svg', 'eps', 'ps', 'pdf', 'tex'
pl.show(screenshot='multiline_title_test.png')
pl.close()
</code></pre>
<p><strong>Question: is there a way to preserve multiline at svg export?</strong> (using pyvista or maybe vtk)</p>
<p><strong>Edit 1:</strong> as I advance in understanding of the problem (but not of the solution so far):</p>
<p>The generated svg page includes for text:</p>
<pre><code><text fill="#000000" x="512" y="-5" font-size="45" text-anchor="middle" dy="45" font-family="Helvetica">
first line
second line
third one</text>
</code></pre>
<p>From this link <a href="https://stackoverflow.com/questions/31469134/how-to-display-multiple-lines-of-text-in-svg">How to display multiple lines of text in SVG?</a>, I understand it should include some 'tspan' with x and dy properties. Is this the only way?</p>
 

Latest posts

I
Replies
0
Views
1
impact christian
I
Top