【发布时间】:2015-07-05 13:47:20
【问题描述】:
在我的 javafx 应用程序中,我使用 JavaFX 8 打印 API 打印节点,我遇到了打印区域的问题,尽管我已经用 A4 纸设置了 pageLayout .... 这是我的代码:
public static void printNode(final Node node) throws NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException {
Printer printer = Printer.getDefaultPrinter();
PageLayout pageLayout = printer.createPageLayout(Paper.A4, PageOrientation.PORTRAIT, 0,0,0,0 );
PrinterJob job = PrinterJob.createPrinterJob();
if (job != null && job.showPrintDialog(node.getScene().getWindow()) ) {
boolean success = job.printPage(pageLayout, node);
if (success) {
job.endJob();
}
}
这是我要打印的节点的快照:
这是我打印节点时得到的结果
【问题讨论】: