# vtkTextActor doesn't show multiple lines

**URL:** https://discourse.vtk.org/t/vtktextactor-doesnt-show-multiple-lines/3482
**Category:** Support
**Created:** [June 7, 2020, 1:19pm UTC](https://discourse.vtk.org/t/vtktextactor-doesnt-show-multiple-lines/3482 "2020-06-07T13:19:04Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Marcin\_Krotkiewski](https://discourse.vtk.org/user_avatar/discourse.vtk.org/marcin_krotkiewski/32/1534_2.png) [@Marcin\_Krotkiewski](https://discourse.vtk.org/u/Marcin_Krotkiewski)
#### Post date: [June 7, 2020, 1:19pm UTC](https://discourse.vtk.org/t/vtktextactor-doesnt-show-multiple-lines/3482/1 "2020-06-07T13:19:05Z")

</div>

I am using VTK 9 through the Java bindings. It seems that I cannot force the vtkTextActor to display multiple lines of text. Instead, the newline character “\n” is displayed literally (attached pic). The same is true for the 3D text actor. Does anyone have any clues why?

![Screenshot from 2020-06-07 15-14-54](https://discourse.vtk.org/uploads/default/original/2X/0/02b858e1a40c6c6989f7e32b0672a1efd572a21c.png)

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [June 8, 2020, 5:36pm UTC](https://discourse.vtk.org/t/vtktextactor-doesnt-show-multiple-lines/3482/2 "2020-06-08T17:36:33Z")

</div>

Hi, Marcin,

Can you post the part of the code where you set the text?

regards,

Paulo

---

<div class="post-metadata">

### Author: ![Marcin\_Krotkiewski](https://discourse.vtk.org/user_avatar/discourse.vtk.org/marcin_krotkiewski/32/1534_2.png) [@Marcin\_Krotkiewski](https://discourse.vtk.org/u/Marcin_Krotkiewski)
#### Post date: [June 8, 2020, 5:42pm UTC](https://discourse.vtk.org/t/vtktextactor-doesnt-show-multiple-lines/3482/3 "2020-06-08T17:42:30Z")

</div>

Hi, Paulo!  
I run this from inside MATLAB, so it’s not pure Java. But it goes like this:

```auto
txt = 'line1 \n line2';
va = vtkTextActor();
va.SetInput(txt);
ren.AddActor(va);

```

I have now tried to place the newline character instead of the escaped sequence `"\n"`, and that worked! So

```auto
txt = ['line1 ' char(10) 'line2'];
[...]

```

gives me what I need. Which is OK, but I expected the escaped sequence to work…

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [June 8, 2020, 5:46pm UTC](https://discourse.vtk.org/t/vtktextactor-doesnt-show-multiple-lines/3482/4 "2020-06-08T17:46:46Z")

</div>

I was suspecting that. MATLAB is certainly transforming `\n` into `\\n`, which is parsed as a literal `\n` instead of the escape sequence. Metacharacters vary from language to language.

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [June 8, 2020, 5:48pm UTC](https://discourse.vtk.org/t/vtktextactor-doesnt-show-multiple-lines/3482/5 "2020-06-08T17:48:08Z")

</div>

See this: [https://www.mathworks.com/help/matlab/ref/newline.html](https://www.mathworks.com/help/matlab/ref/newline.html) .

---

<div class="post-metadata">

### Author: ![Marcin\_Krotkiewski](https://discourse.vtk.org/user_avatar/discourse.vtk.org/marcin_krotkiewski/32/1534_2.png) [@Marcin\_Krotkiewski](https://discourse.vtk.org/u/Marcin_Krotkiewski)
#### Post date: [June 9, 2020, 1:39pm UTC](https://discourse.vtk.org/t/vtktextactor-doesnt-show-multiple-lines/3482/6 "2020-06-09T13:39:17Z")

</div>

Thanks. I guess I misunderstood the documentation and expected the escaped sequence to work…

---

<div class="post-metadata">

### Author: ![sherinnovation](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/s/b487fb/32.png) [@sherinnovation](https://discourse.vtk.org/u/sherinnovation)
#### Post date: [February 9, 2022, 8:57pm UTC](https://discourse.vtk.org/t/vtktextactor-doesnt-show-multiple-lines/3482/7 "2022-02-09T20:57:31Z")

</div>

The escape sequence will work. Try using the following

```auto
textActor.SetInput("First Line \r\n Second Line")

```
