private void save(File file,String extension) throws IOException {
  java.awt.Color paper=fxToAWTColor(background);
  java.awt.Color ink=fxToAWTColor(foreground);
  BufferedImage image=new BufferedImage((barcode.getWidth() * zoom) + (2 * border),(barcode.getHeight() * zoom) + (2 * border),BufferedImage.TYPE_INT_RGB);
  Graphics2D g2d=image.createGraphics();
  g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
  g2d.setColor(paper);
  g2d.fillRect(0,0,(barcode.getWidth() * zoom) + (2 * border),(barcode.getHeight() * zoom) + (2 * border));
  Java2DRenderer renderer=new Java2DRenderer(g2d,zoom,border,paper,ink);
  renderer.render(barcode);
  ImageIO.write(image,extension,file);
}

private void save ( File file , String extension ) throws IOException { java . awt . Color paper = fxToAWTColor ( background ) ; java . awt . Color ink = fxToAWTColor ( foreground ) ; BufferedImage image = new BufferedImage ( ( barcode . getWidth ( ) * zoom ) + ( 2 * border ) , ( barcode . getHeight ( ) * zoom ) + ( 2 * border ) , BufferedImage . TYPE_INT_RGB ) ; Graphics2D g2d = image . createGraphics ( ) ; g2d . setRenderingHint ( RenderingHints . KEY_ANTIALIASING , RenderingHints . VALUE_ANTIALIAS_ON ) ; g2d . setColor ( paper ) ; g2d . fillRect ( 0 , 0 , ( barcode . getWidth ( ) * zoom ) + ( 2 * border ) , ( barcode . getHeight ( ) * zoom ) + ( 2 * border ) ) ; Java2DRenderer renderer = new Java2DRenderer ( g2d , zoom , border , paper , ink ) ; renderer . render ( barcode ) ; ImageIO . write ( image , extension , file ) ; }
save the barcode to a file .
