public static BufferedImage renderToImage(String url,int width,int height,int bufferedImageType){
  Graphics2DRenderer g2r=new Graphics2DRenderer();
  g2r.setDocument(url);
  Dimension dim=new Dimension(width,height);
  BufferedImage buff=new BufferedImage((int)dim.getWidth(),(int)dim.getHeight(),bufferedImageType);
  Graphics2D g=(Graphics2D)buff.getGraphics();
  g2r.layout(g,dim);
  g2r.render(g);
  g.dispose();
  return buff;
}

public static BufferedImage renderToImage ( String url , int width , int height , int bufferedImageType ) { Graphics2DRenderer g2r = new Graphics2DRenderer ( ) ; g2r . setDocument ( url ) ; Dimension dim = new Dimension ( width , height ) ; BufferedImage buff = new BufferedImage ( ( int ) dim . getWidth ( ) , ( int ) dim . getHeight ( ) , bufferedImageType ) ; Graphics2D g = ( Graphics2D ) buff . getGraphics ( ) ; g2r . layout ( g , dim ) ; g2r . render ( g ) ; g . dispose ( ) ; return buff ; }
a static utility method to automatically create an image from a document . the buffered image type must be specified .
