I'm trying to print a TableView in JavaFX application. When I pass the TableView directly to the PrinterJob.printPage(TableView) the text data is in some other language but the view shows up fine i.e in English on the screen.
...
final TableView addItemTableView = (TableView) tabAnchorpane.getChildren().get(1);
Printer printer = Printer.getDefaultPrinter();
PageLayout pageLayout = printer.createPageLayout(Paper.A4, PageOrientation.LANDSCAPE, Printer.MarginType.DEFAULT);
double scaleX = pageLayout.getPrintableWidth() / addItemTableView.getBoundsInParent().getWidth();
Scale scale = new Scale(scaleX, scaleX);
addItemTableView.getTransforms().add(scale);
PrinterJob printerJob = PrinterJob.createPrinterJob();
if (printerJob.showPrintDialog(stage.getOwner()) && printerJob.printPage(pageLayout, addItemTableView)) {
printerJob.endJob();
}
...
The TableView is populated with data from the Task class
public class Task implements Serializable {
private static final long serialVersionUID = 2L;
private transient StringProperty description;
private transient IntegerProperty priority;
private transient ObjectProperty<LocalDate> dueDate;
private transient StringProperty status;
private transient ObjectProperty<LocalDate> startDate;
private transient ObjectProperty<LocalDate> endDate;
...
}
The issue seems to be with JDK 7. When I switched to JDK 10 the issue is resolved. The print preview pages show up in English as expected.