title: Printable prints BufferedImage with incorrect size
body: <p>So yeah what I am trying here is printing a BufferedImage, all works just fine until you see the outcome. The outcome is to big, the print is to large and doesn't it scales up everything when printing for some reason.
  I used <code>((MM * DPI)/25,4)</code> to calculate the correct pixel length according to paper size from Millimeters but when I print it its to big.</p>
  
  <p>This is the code I wrote for it:</p>
  
  <pre><code>package frik.main;
  
  import java.awt.Color;
  import java.awt.Graphics;
  import java.awt.Graphics2D;
  import java.awt.image.BufferedImage;
  import java.awt.print.PageFormat;
  import java.awt.print.Printable;
  import java.awt.print.PrinterException;
  import java.awt.print.PrinterJob;
  
  import javax.swing.ImageIcon;
  import javax.swing.JFrame;
  import javax.swing.JLabel;
  import javax.swing.JOptionPane;
  import javax.swing.JPanel;
  import javax.swing.UIManager;
  
  import java.awt.event.*;
  
  import javax.swing.*;
  import frik.data.Config;
  import frik.utils.ImgUtil;
  
  public class Previewer implements Config, Printable, ActionListener{
  
      private JFrame Frame;
      private JPanel ImagePanel;
      private JLabel PicLabel;
      private JButton PrintButton;
      private static BufferedImage before;
      private static boolean Scaled;
  
      public Previewer(BufferedImage Image, boolean scaled){
          this.before = Image;
          this.Scaled = scaled;
          loop();
  
      }
  
      public int print(Graphics g, PageFormat pf, int page) throws PrinterException{
          if (page &gt; 0) { 
              return Printable.NO_SUCH_PAGE;
          }
          Graphics2D g2d = (Graphics2D)g;
          g2d.translate(pf.getImageableX(), pf.getImageableY());
  
          g.drawImage(0, 0, null);
  
          return Printable.PAGE_EXISTS;
      }
  
      public void actionPerformed(ActionEvent e){
          PrinterJob job = PrinterJob.getPrinterJob();
          job.setPrintable(this);
          boolean ok = job.printDialog();
          if (ok) {
              try {
                  job.print();
              } catch (PrinterException ex) {
                  JOptionPane.showMessageDialog(null, "The Printjob did not successfully complete.", "Print Failure.", JOptionPane.WARNING_MESSAGE);
              }
          }
      }
  
      public void loop(){
          UIManager.put("swing.boldMetal", Boolean.FALSE);
          Frame = new JFrame("Mold Preview");
          ImagePanel = new JPanel();
          PrintButton = new JButton("Print Mold");
  
          Frame.addWindowListener(new WindowAdapter() {
                 public void windowClosing(WindowEvent e) {System.exit(0);}
              });
  
          if(Scaled){
              PicLabel = new JLabel(new ImageIcon(ImgUtil.scaleImage(PAPER_WIDTH / 3, PAPER_HEIGHT / 3, before)));
          }else if (!Scaled){
              PicLabel = new JLabel(new ImageIcon(before));
          }
  
          ImagePanel.setBackground(Color.orange);
          ImagePanel.add(PicLabel);
          Frame.add("Center", ImagePanel);
  
          PrintButton.addActionListener(this);
          Frame.add("North", PrintButton);
  
          Frame.pack();
          Frame.setVisible(true);
          Frame.setResizable(false);
  
      }
  
      public static void main(String args[]){
          new Previewer(before, Scaled);
          //////////////////////////////
      }
  }
  </code></pre>
  
  <p>So if someone could help me scale the image before printing it according to the printers scale factor, because I am assuming the printers DPI is causing this, so that the image is the exact size in Millimeters when printed exact to the size input in pixels. <br>
  That would be great.</p>