Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/392.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
有没有一种方法可以使用javaFX在一张纸上打印多个节点?_Java_Javafx_Printing_Nodes - Fatal编程技术网

有没有一种方法可以使用javaFX在一张纸上打印多个节点?

有没有一种方法可以使用javaFX在一张纸上打印多个节点?,java,javafx,printing,nodes,Java,Javafx,Printing,Nodes,我可以在纸上成功打印表格,但如果我还想在同一张纸上打印表格上方的标签,如何实现? 这是我的打印代码: private void print(Node node) { Printer printer = Printer.getDefaultPrinter(); PageLayout pageLayout = printer.createPageLayout(Paper.A4, PageOrientation.PORTRAIT, Printer.MarginType.HARDWARE

我可以在纸上成功打印表格,但如果我还想在同一张纸上打印表格上方的标签,如何实现? 这是我的打印代码:

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();
    double scaleX = pageLayout.getPrintableWidth() / node.getBoundsInParent().getWidth();                
    Scale scale = new Scale(scaleX, 1);
    node.getTransforms().add(scale);

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

    node.getTransforms().remove(scale);
}
我在按钮中调用
print
方法,如下所示:

printButton.setOnAction(e -> print(table));

有什么想法吗?

只需将节点像窗格一样放入容器中,然后打印此窗格。窗格本身就是一个节点。

我考虑过,但软件体系结构非常混乱:(