本文整理汇总了Java中javafx.print.PrinterJob.showPrintDialog方法的典型用法代码示例。如果您正苦于以下问题:Java PrinterJob.showPrintDialog方法的具体用法?Java PrinterJob.showPrintDialog怎么用?Java PrinterJob.showPrintDialog使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.print.PrinterJob
的用法示例。
在下文中一共展示了PrinterJob.showPrintDialog方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: acaoImprimir
import javafx.print.PrinterJob; //导入方法依赖的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();
}
}
示例2: handlePrintButton
import javafx.print.PrinterJob; //导入方法依赖的package包/类
@FXML
private void handlePrintButton(ActionEvent event) {
Printer printer = Printer.getDefaultPrinter();
printer.createPageLayout(Paper.A4, PageOrientation.PORTRAIT, Printer.MarginType.EQUAL);
PrinterJob job = PrinterJob.createPrinterJob(printer);
job.showPrintDialog(owner);
if (job != null) {
engine.print(job);
job.endJob();
}
}
示例3: handlePrintButton
import javafx.print.PrinterJob; //导入方法依赖的package包/类
@FXML
private void handlePrintButton(ActionEvent event) {
Printer printer = Printer.getDefaultPrinter();
printer.createPageLayout(Paper.A4, PageOrientation.PORTRAIT, Printer.MarginType.EQUAL);
PrinterJob job = PrinterJob.createPrinterJob(printer);
job.showPrintDialog(owner);
if (job != null) {
engine.print(job);
job.endJob();
}
}
示例4: printImage
import javafx.print.PrinterJob; //导入方法依赖的package包/类
/**
* Print image.
*/
@FXML
public void printImage() {
PrinterJob printerJob = PrinterJob.createPrinterJob();
printerJob.showPrintDialog(printNode.getScene().getWindow());
if (printerJob != null) {
boolean success = printerJob.printPage(printNode);
if (success) {
printerJob.endJob();
}
}
}
示例5: printActiveFile
import javafx.print.PrinterJob; //导入方法依赖的package包/类
@Override
public void printActiveFile()
{
CodeEditor activeEditor = getActiveCodeEditor();
if (activeEditor == null)
{
Dialogues.showActionFailedDialogue("No file is open!");
return;
}
PrinterJob printAction = PrinterJob.createPrinterJob();
if (printAction == null)
{
Dialogues.showActionFailedDialogue("Unable to access system print utilities");
return;
}
boolean notCancelled = printAction.showPrintDialog(stage);
if (notCancelled)
{
boolean success = printAction.printPage(activeEditor);
if (success)
printAction.endJob();
else
Dialogues.showActionFailedDialogue("Print may have failed");
}
}
示例6: printJob
import javafx.print.PrinterJob; //导入方法依赖的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();
}
示例7: showPrintDialog
import javafx.print.PrinterJob; //导入方法依赖的package包/类
@Override
public boolean showPrintDialog(PrinterJob job) {
return job.showPrintDialog(null);
}