# Getting size of vtkTextActor in python

**URL:** https://discourse.vtk.org/t/getting-size-of-vtktextactor-in-python/3578
**Category:** Support
**Created:** [June 17, 2020, 2:40pm UTC](https://discourse.vtk.org/t/getting-size-of-vtktextactor-in-python/3578 "2020-06-17T14:40:16Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Nibba2018](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/n/e99b99/32.png) [@Nibba2018](https://discourse.vtk.org/u/Nibba2018)
#### Post date: [June 17, 2020, 2:40pm UTC](https://discourse.vtk.org/t/getting-size-of-vtktextactor-in-python/3578/1 "2020-06-17T14:40:16Z")

</div>

Hello everyone, I would like to know the width and height of a vtkTextActor in python. According to the documentation, the `GetSize` and `GetBoundingBox` should provide me the height and width and those said methods require `vtkViewport` as one of its parameters. But I wanted to gain this information without passing a `vtkViewport` instance. Also, I tried the `GetPosition2` method but its value is always set to `(0.5, 0.5, 0)` irrespective of the font size of vtkTextActor. It would be great if someone could provide me way to gain this information.

Thank You.

---

<div class="post-metadata">

### Author: ![AllisonVacanti](https://discourse.vtk.org/user_avatar/discourse.vtk.org/allisonvacanti/32/2396_2.png) [@AllisonVacanti](https://discourse.vtk.org/u/AllisonVacanti)
#### Post date: [June 20, 2020, 2:30am UTC](https://discourse.vtk.org/t/getting-size-of-vtktextactor-in-python/3578/2 "2020-06-20T02:30:41Z")

</div>

> [@Nibba2018](#):
>
> According to the documentation, the `GetSize` and `GetBoundingBox` should provide me the height and width and those said methods require `vtkViewport` as one of its parameters. But I wanted to gain this information without passing a `vtkViewport` instance.

It’s not possible to determine the pixel size of the rendered text without the viewport, since the size of the rendered text is dependent on the DPI of the target display.

A `vtkRenderer` is a type of `vtkViewport`, so you should pass in the renderer that draws the actor.

> [@Nibba2018](#):
>
> Also, I tried the `GetPosition2` method but its value is always set to `(0.5, 0.5, 0)` irrespective of the font size of vtkTextActor.

The `Position2` coordinate is not used unless the `TEXT_SCALE_MODE_PROP` mode is being used on the text actor. See [`vtkTextActor::SetTextScaleModeToProp()`](https://vtk.org/doc/nightly/html/classvtkTextActor.html#ac4eea2af311831bbda961247684ff410).

---

<div class="post-metadata">

### Author: ![Nibba2018](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/n/e99b99/32.png) [@Nibba2018](https://discourse.vtk.org/u/Nibba2018)
#### Post date: [June 21, 2020, 2:18pm UTC](https://discourse.vtk.org/t/getting-size-of-vtktextactor-in-python/3578/3 "2020-06-21T14:18:52Z")

</div>

Hello @AllisonVacanti, thank you for your response. Could you suggest me a workaround or a manual method by which I could achieve this?

---

<div class="post-metadata">

### Author: ![AllisonVacanti](https://discourse.vtk.org/user_avatar/discourse.vtk.org/allisonvacanti/32/2396_2.png) [@AllisonVacanti](https://discourse.vtk.org/u/AllisonVacanti)
#### Post date: [June 21, 2020, 2:29pm UTC](https://discourse.vtk.org/t/getting-size-of-vtktextactor-in-python/3578/4 "2020-06-21T14:29:47Z")

</div>

You’ll need to find the instance of `vtkRenderer` that contains the text actor and pass that renderer in as the viewport argument of `GetSize(...)`.
