• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java PageLayout类的典型用法和代码示例

java 1次浏览

本文整理汇总了Java中javafx.print.PageLayout的典型用法代码示例。如果您正苦于以下问题:Java PageLayout类的具体用法?Java PageLayout怎么用?Java PageLayout使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

PageLayout类属于javafx.print包,在下文中一共展示了PageLayout类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: acaoImprimir

点赞 4

import javafx.print.PageLayout; //导入依赖的package包/类
public void acaoImprimir() {
    PageLayout paisagem = Printer.getDefaultPrinter().createPageLayout(Paper.A4, PageOrientation.LANDSCAPE, Printer.MarginType.HARDWARE_MINIMUM);
    Double largura = paisagem.getPrintableWidth()-50;
    Double altura = paisagem.getPrintableHeight()-50;
    PrinterJob trabalho = PrinterJob.createPrinterJob();
    if(trabalho != null){
        if(trabalho.showPrintDialog(Kernel.palco)){
            Tooltip aguarde = Janela.showTooltip(Status.ADVERTENCIA, idioma.getMensagem("aguarde_impressao"));
            tabela.getChildren().remove(barraSuperior);
            trabalho.getJobSettings().setPageLayout(paisagem);
            tabela.setMaxSize(largura, altura);
            ObservableList itens = listaExtrato.getItems();
            for(int i=0; i<itens.size();i+=18){
                int end = (i+18<itens.size()) ? i+18 : itens.size();
                listaExtrato.setItems(FXCollections.observableList(itens.subList(i, end)));
                trabalho.printPage(tabela);
            }
            tabela.add(barraSuperior, 0, 0);
            tabela.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
            listaExtrato.setItems(itens);
            aguarde.hide();
        }
        trabalho.endJob();
    }
}
 

开发者ID:badernageral,
项目名称:bgfinancas,
代码行数:26,
代码来源:RelatoriosControlador.java

示例2: printJob

点赞 3

import javafx.print.PageLayout; //导入依赖的package包/类
/********************************
 * 작성일 : 2016. 6. 29. 작성자 : KYJ
 *
 * print 처리.
 *
 * @param window
 * @param target
 ********************************/
public static void printJob(Window window, Node target) {
	Printer printer = Printer.getDefaultPrinter();
	// PrinterAttributes printerAttributes = printer.getPrinterAttributes();
	//
	Paper a4 = Paper.A4;

	// Paper a4 = PrintHelper.createPaper("Rotate A4", Paper.A4.getHeight(),
	// Paper.A4.getWidth(), Units.MM);
	PageLayout pageLayout = printer.createPageLayout(a4, PageOrientation.REVERSE_PORTRAIT, MarginType.DEFAULT);

	PrinterJob printerJob = PrinterJob.createPrinterJob();

	// JobSettings jobSettings = printerJob.getJobSettings();
	// jobSettings.setPrintSides(PrintSides.TUMBLE);
	ImageView imageView = new ImageView();
	// 화면 사이즈에 맞게 크기 조절.
	Callback<SnapshotResult, Void> callback = param -> {
		final WritableImage image = param.getImage();
		imageView.setImage(image);

		final double scaleX = pageLayout.getPrintableWidth() / imageView.getBoundsInParent().getWidth();
		final double scaleY = pageLayout.getPrintableHeight() / imageView.getBoundsInParent().getHeight();
		imageView.getTransforms().add(new Scale(scaleX, scaleY));

		return null;
	};

	target.snapshot(callback, null, null);

	if (printerJob.showPrintDialog(window) && printerJob.printPage(pageLayout, imageView))
		printerJob.endJob();
}
 

开发者ID:callakrsos,
项目名称:Gargoyle,
代码行数:41,
代码来源:FxUtil.java

示例3: main

点赞 3

import javafx.print.PageLayout; //导入依赖的package包/类
public static void main(String[] args) {

        Printer pdfPrinter = null;

        // Windows: Instal PDF24 from http://en.pdf24.org
        // Linux: Install cups-pdf http://www.cups-pdf.de

        // Optionally PDF24 could be configured for silent mode from
        // "C:\Program Files (x86)\PDF24\pdf24-SettingsUITool.exe" from the Menu "PDF Printer"
        // Set "Automatically save..." checkbox to true

        Iterator<Printer> iter = Printer.getAllPrinters().iterator();
        while (iter.hasNext()) {
            Printer printer = iter.next();
            if (printer.getName().endsWith("PDF")) {
                pdfPrinter = printer;
            }
        }

        String url = PDFPrinting.class.getResource("/sample-page.html").toExternalForm();

        Page page = BrowserFactory
            .getWebKit()
            .navigate(url);

        WebEngine engine = (WebEngine) page.getEngine();

        // Note: Optionally -webkit-print-color-adjust: exact; could be used for fix background-color problem
        // @see http://stackoverflow.com/questions/14987496/background-color-not-showing-in-print-preview

        PrinterJob job = null;
        try {
            page.show();
            // clear margins
            PageLayout layout = pdfPrinter.createPageLayout(Paper.A4, PageOrientation.PORTRAIT, MarginType.HARDWARE_MINIMUM);

            job = PrinterJob.createPrinterJob(pdfPrinter);
            job.getJobSettings().setPageLayout(layout);
            job.getJobSettings().setJobName("Sample Printing Job");

            engine.print(job);
            job.endJob();
        } finally {
            if (job != null) {
                job.endJob();
            }
            page.close();
        }
    }
 

开发者ID:webfolderio,
项目名称:ui4j,
代码行数:50,
代码来源:PDFPrinting.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)