private boolean checkStringLength(String string,String orientation,String fontName,int fontSize){
  Font font=new Font(fontName,Font.PLAIN,fontSize);
  JLabel label=new JLabel();
  FontMetrics metrics=label.getFontMetrics(font);
  int stringWidth=metrics.stringWidth(string);
  return stringWidth <= getPageSize(orientation).width;
}

private boolean checkStringLength ( String string , String orientation , String fontName , int fontSize ) { Font font = new Font ( fontName , Font . PLAIN , fontSize ) ; JLabel label = new JLabel ( ) ; FontMetrics metrics = label . getFontMetrics ( font ) ; int stringWidth = metrics . stringWidth ( string ) ; return stringWidth <= getPageSize ( orientation ) . width ; }
checks to see if the the string fits on the page .
