Fit image exactly into renderWindow

Hi guys. I am following the following VTK example to take a screenshot of my current volume. https://vtk.org/Wiki/VTK/Examples/Cxx/Utilities/Screenshot.

However, the screenshot always comes with added whitespace on either side (see attached). Is there a way to make the window fit the image exactly?

VTK_Examples_Baseline_Utilities_TestSingleScreenshot

The documentation for SetViewAngle() in vtkCamera says to use this view angle:

angle = 2*atan((h/2)/d)

Here h is the height of the object and d is the distance to the camera. For this to work with VTK, you must express the angle in degrees (not radians).

If you are using a parallel projection (camera->ParallelProjectionOn()) then instead of using SetViewAngle() you must use SetParallelScale(h/2).