-1

I have table with only 3 rows and 5 columns, when printing it prints all 3 rows but only 3 columns. This is my code:

  private void print(Node node)        
  Printer printer = Printer.getDefaultPrinter();
  PageLayout pageLayout
    = printer.createPageLayout(Paper.A4, PageOrientation.PORTRAIT, 
  Printer.MarginType.HARDWARE_MINIMUM);
  PrinterJob job = PrinterJob.createPrinterJob();

    if (job != null && job.showPrintDialog(node.getScene().getWindow())) {
        boolean success = job.printPage(node);
        if (success) {
            job.endJob();
        }
    }

This is button:

  printButton.setOnAction(new EventHandler<ActionEvent>() {
        public void handle(ActionEvent event) {
            print(tableView);
        }
    });

What should i do so i can see all columns? i'm using old hp laserjet professional p1102 printer.

nemke nemke
  • 191
  • 1
  • 1
  • 9

1 Answers1

0

JavaFX8 Print API : how to set correctly the Printable area This is where i found answer. I only need to change height:

double scaleX
    = pageLayout.getPrintableWidth() / node.getBoundsInParent().getWidth();
double scaleY
    = pageLayout.getPrintableHeight() / node.getBoundsInParent().getHeight();
Scale scale = new Scale(scaleX, scaleY)//insted of scaleY i put number 1

So it will not stretch table height all over the paper.

nemke nemke
  • 191
  • 1
  • 1
  • 9