title: JAVA - Printing XPS without File Name/Location Pop-up
body: <p>So im writing a java program for my dad to print out receipts and stuff. My original intention was to print out to his Receipt Printer some info regarding each transaction he made. However, the printer has some trouble printing what i send without clipping it to an extreme point.</p>
  
  <p>My next idea, which worked out quite well, was to save the "receipt" into an XPS file and then print the XPS, which would not clip it and would make everything nice. Now, i can print into an XPS file using Microsoft's XPS Document Writer PrintService. The problem is, when i do it, it always pop's up a box asking for the file name and location to save it into.</p>
  
  <p>Is there anyway to set it so as to not show that pop-up at all?</p>
  
  <p>Current code:</p>
  
  <pre><code>PrinterJob job = PrinterJob.getPrinterJob();
  job.setPrintable(this);
  try {
      job.print();
  } catch (PrinterException ex) {
      // The job did not successfully complete 
  }
  </code></pre>
  
  <p>-</p>
  
  <pre><code>@Override
  public int print(Graphics g, PageFormat pf, int page) throws PrinterException {
       String temp;
  
      if (page &gt; 0) { /* We have only one page, and 'page' is zero-based */
          return NO_SUCH_PAGE;
      }
  
      Graphics2D g2d = (Graphics2D)g;
      g2d.translate(pf.getImageableX(), pf.getImageableY());
      int lineSize=20;
  
      Font testFont=new Font("Lucida Console", 0, 20);
      g.setFont(testFont);
  
      g.drawString("      Fatura/Recibo nº"+nmrRec+"      ", 5, 20);
      return PAGE_EXISTS;
  }
  </code></pre>