import javafx.application.Application; import javafx.application.Platform; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.print.PageLayout; import javafx.print.PageOrientation; import javafx.print.Paper; import javafx.print.PrintResolution; import javafx.print.Printer; import javafx.print.PrinterAttributes; import javafx.scene.Scene; import javafx.scene.control.Button; import javafx.scene.layout.StackPane; import javafx.stage.Stage; /** * * @author Alexander */ public class TestPrinting extends Application { @Override public void start(Stage primaryStage) { Printer prn = Printer.getDefaultPrinter(); PrinterAttributes pa = prn.getPrinterAttributes(); //PageLayout pl = prn.createPageLayout(pa.getDefaultPaper(), PageOrientation.PORTRAIT, Printer.MarginType.HARDWARE_MINIMUM); Paper p = pa.getDefaultPaper(); PageLayout pl = prn.createPageLayout(pa.getDefaultPaper(), PageOrientation.PORTRAIT, 6,6,6,6); info("Printer: "+prn.getName()); info(" Default paper = " + p); info(" Default page layout: "+prn.getDefaultPageLayout()); info(" Default copies: "+pa.getDefaultCopies()); info(" Default paper source: "+pa.getDefaultPaperSource()); info(" Supported paper sources: "+pa.getSupportedPaperSources()); info(" Default paper: "+pa.getDefaultPaper()); info(" Supported papers: "); for (Paper ps : pa.getSupportedPapers()) info(" "+ps); info(" Default print resolution: "+pa.getDefaultPrintResolution()); info(" Supported resolutions: "); for (PrintResolution pr : pa.getSupportedPrintResolutions()) info(" "+pr); info(" Default print quality: "+pa.getDefaultPrintQuality()); info(" Default print sides: "+pa.getDefaultPrintSides()); info(" Default collation: "+pa.getDefaultCollation()); info(" ----------------------------"); info(" Printable size: "+pl.getPrintableWidth()+"x"+pl.getPrintableHeight()+", border: "+pl.getLeftMargin()+","+pl.getTopMargin()+","+pl.getRightMargin()+","+pl.getBottomMargin()); info(" Paper size: "+pl.getPaper().getWidth()+"x"+pl.getPaper().getHeight()); Platform.exit(); } public static void main(String[] args) { launch(args); } private static void info(String msg) { System.out.println(msg); } }