0 Replies Latest reply: Jul 1, 2011 12:43 AM by 673647 RSS

    Printing multi page document

    673647
      Hi all

      I have been struggling with the printing in batch for an application I wrote.

      The program renders SVGDocuments (Batik) and after I render 1, I send it to the printer. So far so good. In batch this means that it looks like this:

      * render
      - print
      * render
      - print

      But the problem is that between the rendering and printing, someone else can send a document to the printer and this document will be somewhere between
      the papers of the application.

      So what I would like to have is that I can send only one printer job that includes all the pages.

      I tried it with the java.awt.Book object and I can see 17 pages, but only the first one is printed. Here is the code:


      Book book = new Book();
      PageFormat documentPageFormat = new PageFormat();
      documentPageFormat.setOrientation(PageFormat.LANDSCAPE);
      for (PrintTranscoder printTranscoder : printSVGService.getPrintTranscoders()) {
      book.append(printTranscoder, documentPageFormat);
      }

      PrinterJob printJob = PrinterJob.getPrinterJob();
      try {
      printJob.setPageable(book);
      printJob.print();
      } catch (PrinterException e) {
      e.printStackTrace();
      }

      Can someone tell me why only the first page is printed? Because when I debug the "book" object holds 17 documents. But only the first one is printed.

      Thanks
      Xnni