public void print(HashPrintRequestAttributeSet aset) {

    try {
      for (int pos = 0; pos < smallCraftList.size(); pos++) {
        PrinterJob pj = PrinterJob.getPrinterJob();
        pj.setPrintService(masterPrintJob.getPrintService());

        aset.add(PrintQuality.HIGH);

        PageFormat pageFormat = new PageFormat();
        pageFormat = pj.getPageFormat(null);

        Paper p = pageFormat.getPaper();
        p.setImageableArea(0, 0, p.getWidth(), p.getHeight());
        pageFormat.setPaper(p);

        pj.setPrintable(this, pageFormat);
        smallCraft = smallCraftList.get(pos);
        pj.setJobName(smallCraft.getChassis() + " " + smallCraft.getModel());

        try {
          pj.print(aset);
        } catch (Exception ex) {
          ex.printStackTrace();
        }
        System.gc();
      }
    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }
Beispiel #2
0
  public static void main(String[] args) {

    for (int i = 0; i < instructions.length; i++) {
      System.out.println(instructions[i]);
    }

    PrinterJob job = PrinterJob.getPrinterJob();
    if (job.getPrintService() == null || !job.printDialog()) {
      return;
    }

    System.out.println("Job copies is " + job.getCopies());

    if (job.getCopies() == 1) {
      throw new RuntimeException("Copies not incremented");
    }
  }
Beispiel #3
0
  public static void main(String args[]) throws Exception {
    for (int i = 0; i < instr.length; i++) {
      System.out.println(instr[i]);
    }
    PrinterJob job = PrinterJob.getPrinterJob();
    if (job.getPrintService() == null) {
      System.out.println("No printers. Test cannot continue.");
      return;
    }
    job.setPrintable(new PageRanges());
    if (!job.printDialog()) {
      return;
    }
    job.print();
    if (!job.printDialog()) {
      return;
    }
    job.print();

    return;
  }