在我的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();
}
}
Run Code Online (Sandbox Code Playgroud)
以下是我要打印的节点的快照:
这是我打印节点时得到的内容