I wrote a python script to render a VTK object and save its figure as PNG using the vtkPNGWriter()
functions. Is there a way to save it as a PDF or a svg file?
It is possible to export a PDF image of the render window using the function vtk.vtkGL2PSExporter()
.
Here a working snippet of code:
pdfExporter = vtk.vtkGL2PSExporter()
pdfExporter.SetRenderWindow(render_window)
outputFilename = "file_name"
pdfExporter.SetFileFormatToPDF() #save as pdf
pdfExporter.SetFilePrefix(outputFilename)
pdfExporter.Write()