# How to save the graphics file created by the widget

**URL:** https://discourse.vtk.org/t/how-to-save-the-graphics-file-created-by-the-widget/8053
**Category:** Web
**Created:** [March 15, 2022, 2:47am UTC](https://discourse.vtk.org/t/how-to-save-the-graphics-file-created-by-the-widget/8053 "2022-03-15T02:47:38Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![3xxx](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/3/97f17d/32.png) [@3xxx](https://discourse.vtk.org/u/3xxx)
#### Post date: [March 15, 2022, 2:47am UTC](https://discourse.vtk.org/t/how-to-save-the-graphics-file-created-by-the-widget/8053/1 "2022-03-15T02:47:38Z")

</div>

Dear VTK team,

I draw the lines with the mouse and want to save then like .vtk file, see the example [LineWidget](https://kitware.github.io/vtk-js/examples/LineWidget.html)  
I’m looking for a way to save all the lines data to an file in VTK.js. Could you please advice me something?  
Thank you.

---

<div class="post-metadata">

### Author: ![Forrest](https://discourse.vtk.org/user_avatar/discourse.vtk.org/forrest/32/300_2.png) [@Forrest](https://discourse.vtk.org/u/Forrest)
#### Post date: [March 15, 2022, 1:52pm UTC](https://discourse.vtk.org/t/how-to-save-the-graphics-file-created-by-the-widget/8053/2 "2022-03-15T13:52:29Z")

</div>

For the LineWidget example, you will have to manually extract your state and save it.

```auto
state = getWidgetState()
serializedState = {
  handle1: state.getHandle1().getOrigin(),
  handle2: state.getHandle2().getOrigin(),
}

```

You could also try to use `state.getState()`, which should output a serialized form, but I don’t remember if there were cyclic issues with the widget state object. Probably not, so it’s worth a try.

---

<div class="post-metadata">

### Author: ![3xxx](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/3/97f17d/32.png) [@3xxx](https://discourse.vtk.org/u/3xxx)
#### Post date: [March 15, 2022, 3:56pm UTC](https://discourse.vtk.org/t/how-to-save-the-graphics-file-created-by-the-widget/8053/3 "2022-03-15T15:56:44Z")

</div>

Thanks for your help. 😀  
I’ll try
