如何将VTK截图导出为PDF或矢量化图像?

huangapple go评论151阅读模式
英文:

How can I export a VTK screenshot to a PDF or a vectorized image?

问题

有没有办法将其保存为PDF或SVG文件?

英文:

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?

答案1

得分: 0

你可以使用 vtk.vtkPDFExporter() 将渲染数据导出为 PDF。

英文:

You can use vtk.vtkPDFExporter() to get rendered data as pdf.

答案2

得分: 0

可以使用vtk.vtkGL2PSExporter()函数将渲染窗口导出为PDF图像。以下是一个可用的代码片段:

pdfExporter = vtk.vtkGL2PSExporter()
pdfExporter.SetRenderWindow(render_window)

outputFilename = "文件名"

pdfExporter.SetFileFormatToPDF()  #保存为PDF
pdfExporter.SetFilePrefix(outputFilename)
pdfExporter.Write()
英文:

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()

huangapple
  • 本文由 发表于 2023年6月5日 15:52:50
  • 转载请务必保留本文链接:https://go.coder-hub.com/76404463.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定