title: JavaFX: printing a node across multiple pages
body: <p>I tried to get in touch with the new printing API of JavaFX that was introduced in JDK 8.</p>
  
  <p>Consider the following test program:</p>
  
  <pre><code>import javafx.application.Application;
  import javafx.print.PrinterJob;
  import javafx.scene.Node;
  import javafx.scene.Scene;
  import javafx.scene.control.Button;
  import javafx.scene.control.ToolBar;
  import javafx.scene.layout.BorderPane;
  import javafx.scene.paint.Color;
  import javafx.scene.shape.Rectangle;
  import javafx.stage.Stage;
  
  public class SimplePrintingTest extends Application {
  
    private PrinterJob job = PrinterJob.createPrinterJob();
  
    public static void main(String[] args) {
      launch(args);
    }
  
    @Override
    public void start(Stage primaryStage) {
      BorderPane pane = new BorderPane();
  
      final Rectangle rect = new Rectangle(0, 0, 1000, 1000);
      pane.setCenter(rect);
  
      final ToolBar value = new ToolBar();
  
      final Button print = new Button("print");
      final Button dialog = new Button("print dialog");
      final Button pageLayout = new Button("page layout settings");
      value.getItems().add(print);
      value.getItems().add(dialog);
      value.getItems().add(pageLayout);
      print.setOnAction(event -&gt; print(pane));
      dialog.setOnAction(event -&gt; showPrintDialog(primaryStage));
      pageLayout.setOnAction(event -&gt; showPageSetupDialog(primaryStage));
  
      pane.setTop(value);
      Scene scene = new Scene(pane, 1200, 1024, Color.GRAY);
      primaryStage.setScene(scene);
      primaryStage.show();
    }
  
    public void print(Node node) {
      if (job != null) {      
        // -- ???
        boolean success = job.printPage(node);
        if (success) {
          job.endJob();
          job = PrinterJob.createPrinterJob();
        }
      }
    }
  
    public void showPageSetupDialog(Stage stage) {
      if (job != null) {
        job.showPageSetupDialog(stage);
      }
    }
  
    public void showPrintDialog(Stage stage) {
      if (job != null) {
        job.showPrintDialog(stage);
      }
    }
  }
  </code></pre>
  
  <p>my question is now: How do I configure or use the printer job to print the content of the scene that is (obviously) too big for one page across multiple pages?
  I have tried to set the page ranges like this </p>
  
  <pre><code>job.getJobSettings().setPageRanges(new PageRange(1, 5));
  </code></pre>
  
  <p>or this</p>
  
  <pre><code>job.getJobSettings().setPageRanges(new PageRange(1, 1), new PageRange(2, 2));
  </code></pre>
  
  <p>or change the page range between to printPage calls like this</p>
  
  <pre><code>job.getJobSettings().setPageRanges(new PageRange(1, 1));
  boolean success = job.printPage(node);
  job.getJobSettings().setPageRanges(new PageRange(2, 2));
  success &amp;= job.printPage(node);
  </code></pre>
  
  <p>but nothing seems to work. Always only the left half of the content is visible on the printed document for each time I call printPage. To be clear: I don't want to scale down the node that is printed to fit onto one page, I want to keep the size of the node and print it completely over mutiple pages. This was possible in Swing. Is it not possible anymore in JavaFX?</p>