* @param viewHeight height of the view
* @return the requested scale factor
* @throws FOPException in case of an error while fetching the PageViewport
*/
public double getScaleToFit(double viewWidth, double viewHeight) throws FOPException {
PageViewport pageViewport = renderer.getPageViewport(currentPage);
Rectangle2D pageSize = pageViewport.getViewArea();
float screenResolution = Toolkit.getDefaultToolkit().getScreenResolution();
float screenFactor = screenResolution / UnitConv.IN2PT;
double widthScale = viewWidth / (pageSize.getWidth() / 1000f) / screenFactor;
double heightScale = viewHeight / (pageSize.getHeight() / 1000f) / screenFactor;
return Math.min(displayMode == CONT_FACING ? widthScale / 2 : widthScale, heightScale);