I hava a javafx application where the user enters some details in test fields and it is shown on a listview. I now have a button to print using the printjob but everytime I hit the print button the printer prints garbage data like jhsjs6sh3#uhbsbkahi
instead of the real values from the ListView. below is my codes for the print functon
public void print (final Node node) {
Printer printer = Printer.getDefaultPrinter();
PageLayout pageLayout = printer.createPageLayout(Paper.A4, PageOrientation.PORTRAIT, Printer.MarginType.HARDWARE_MINIMUM);
final double scaleX = pageLayout.getPrintableWidth() / node.getBoundsInParent().getWidth();
final double scaleY = pageLayout.getPrintableHeight() / node.getBoundsInParent().getHeight();
node.getTransforms().add(new Scale(scaleX, scaleY));
PrinterJob job =PrinterJob.createPrinterJob();
if (job != null ){
boolean success = job.printPage(node);
System.out.println("printed");
if (success){
System.out.println(success);
job.endJob();
}
}
}
@FXML
private void printOps(ActionEvent event){
print(billingDataList);
}
I use a MacBook for my development and HP printer.