Search in sources :

Example 1 with Paper

use of javafx.print.Paper in project Gargoyle by callakrsos.

the class FxUtil method printJob.

/********************************
	 * 작성일 : 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();
}
Also used : StageStyle(javafx.stage.StageStyle) PageOrientation(javafx.print.PageOrientation) Printer(javafx.print.Printer) SnapshotParameters(javafx.scene.SnapshotParameters) Transition(javafx.animation.Transition) AnimationType(jidefx.animation.AnimationType) PageLayout(javafx.print.PageLayout) TabPane(javafx.scene.control.TabPane) FontPosture(javafx.scene.text.FontPosture) Map(java.util.Map) Point2D(javafx.geometry.Point2D) PopOver(org.controlsfx.control.PopOver) Rectangle2D(javafx.geometry.Rectangle2D) Pair(javafx.util.Pair) Set(java.util.Set) SnapshotResult(javafx.scene.SnapshotResult) KeyEvent(javafx.scene.input.KeyEvent) Screen(javafx.stage.Screen) ScmCommitComposite(com.kyj.fx.voeditor.visual.component.scm.ScmCommitComposite) Platform(javafx.application.Platform) Stream(java.util.stream.Stream) Region(javafx.scene.layout.Region) FxContextManager(com.kyj.fx.voeditor.visual.framework.contextmenu.FxContextManager) ObservableList(javafx.collections.ObservableList) BorderPane(javafx.scene.layout.BorderPane) MouseButton(javafx.scene.input.MouseButton) TreeItem(javafx.scene.control.TreeItem) DockNode(com.kyj.fx.voeditor.visual.component.dock.pane.DockNode) Supplier(java.util.function.Supplier) ArrayList(java.util.ArrayList) FXMLLoader(javafx.fxml.FXMLLoader) GargoyleButtonBuilder(com.kyj.fx.voeditor.visual.framework.builder.GargoyleButtonBuilder) Color(javafx.scene.paint.Color) Properties(java.util.Properties) TitledPane(javafx.scene.control.TitledPane) Node(javafx.scene.Node) PopupFeatures(javafx.scene.web.PopupFeatures) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) File(java.io.File) FileChooser(javafx.stage.FileChooser) Tab(javafx.scene.control.Tab) ImageView(javafx.scene.image.ImageView) ObservableValue(javafx.beans.value.ObservableValue) SkinManager(com.kyj.fx.voeditor.visual.momory.SkinManager) Image(javafx.scene.image.Image) Button(javafx.scene.control.Button) URL(java.net.URL) LoggerFactory(org.slf4j.LoggerFactory) JavaTextArea(com.kyj.fx.voeditor.visual.component.text.JavaTextArea) ToExcelFileFunction(com.kyj.fx.voeditor.visual.functions.ToExcelFileFunction) WebEvent(javafx.scene.web.WebEvent) JavaSVNManager(com.kyj.scm.manager.svn.java.JavaSVNManager) SvnChagnedCodeComposite(com.kyj.fx.voeditor.visual.component.scm.SvnChagnedCodeComposite) Parent(javafx.scene.Parent) FileSystemView(javax.swing.filechooser.FileSystemView) Task(javafx.concurrent.Task) InstanceTypes(com.kyj.fx.voeditor.visual.framework.InstanceTypes) ImageIO(javax.imageio.ImageIO) WindowEvent(javafx.stage.WindowEvent) TableView(javafx.scene.control.TableView) Method(java.lang.reflect.Method) AutoCompletionTextFieldBinding(impl.org.controlsfx.autocompletion.AutoCompletionTextFieldBinding) FxSVNHistoryDataSupplier(com.kyj.fx.voeditor.visual.component.scm.FxSVNHistoryDataSupplier) TextField(javafx.scene.control.TextField) GargoyleLoadBar(com.kyj.fx.voeditor.visual.component.bar.GargoyleLoadBar) Paper(javafx.print.Paper) BufferedImage(java.awt.image.BufferedImage) Predicate(java.util.function.Predicate) FXMLController(com.kyj.fx.voeditor.visual.framework.annotation.FXMLController) Font(javafx.scene.text.Font) Icon(javax.swing.Icon) Collectors(java.util.stream.Collectors) FxPostInitialize(com.kyj.fx.voeditor.visual.framework.annotation.FxPostInitialize) MarginType(javafx.print.Printer.MarginType) List(java.util.List) Modifier(java.lang.reflect.Modifier) Scale(javafx.scene.transform.Scale) Optional(java.util.Optional) FontWeight(javafx.scene.text.FontWeight) AnimationUtils(jidefx.animation.AnimationUtils) Scene(javafx.scene.Scene) GargoyleBuilderFactory(com.kyj.fx.voeditor.visual.framework.builder.GargoyleBuilderFactory) WebEngine(javafx.scene.web.WebEngine) TextArea(javafx.scene.control.TextArea) MouseEvent(javafx.scene.input.MouseEvent) WebViewConsole(com.kyj.fx.voeditor.visual.component.console.WebViewConsole) Function(java.util.function.Function) TableColumn(javafx.scene.control.TableColumn) TableCell(javafx.scene.control.TableCell) Charset(java.nio.charset.Charset) State(javafx.concurrent.Worker.State) JavaTextView(com.kyj.fx.voeditor.visual.component.popup.JavaTextView) Callback(javafx.util.Callback) Tooltip(javafx.scene.control.Tooltip) GargoyleException(com.kyj.fx.voeditor.visual.exceptions.GargoyleException) FxMemory(com.kyj.fx.voeditor.visual.momory.FxMemory) PrinterJob(javafx.print.PrinterJob) OutputStream(java.io.OutputStream) KeyCode(javafx.scene.input.KeyCode) WebView(javafx.scene.web.WebView) Modality(javafx.stage.Modality) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) CloseableParent(com.kyj.fx.voeditor.visual.main.layout.CloseableParent) TablePosition(javafx.scene.control.TablePosition) WritableImage(javafx.scene.image.WritableImage) FileInputStream(java.io.FileInputStream) Consumer(java.util.function.Consumer) GargoyleSynchLoadBar(com.kyj.fx.voeditor.visual.component.bar.GargoyleSynchLoadBar) Stage(javafx.stage.Stage) Closeable(java.io.Closeable) SwingFXUtils(javafx.embed.swing.SwingFXUtils) Window(javafx.stage.Window) ChangeListener(javafx.beans.value.ChangeListener) InputStream(java.io.InputStream) SharedMemory(com.kyj.fx.voeditor.visual.momory.SharedMemory) WritableImage(javafx.scene.image.WritableImage) SnapshotResult(javafx.scene.SnapshotResult) PageLayout(javafx.print.PageLayout) Paper(javafx.print.Paper) Scale(javafx.scene.transform.Scale) ImageView(javafx.scene.image.ImageView) Printer(javafx.print.Printer) PrinterJob(javafx.print.PrinterJob)

Aggregations

GargoyleLoadBar (com.kyj.fx.voeditor.visual.component.bar.GargoyleLoadBar)1 GargoyleSynchLoadBar (com.kyj.fx.voeditor.visual.component.bar.GargoyleSynchLoadBar)1 WebViewConsole (com.kyj.fx.voeditor.visual.component.console.WebViewConsole)1 DockNode (com.kyj.fx.voeditor.visual.component.dock.pane.DockNode)1 JavaTextView (com.kyj.fx.voeditor.visual.component.popup.JavaTextView)1 FxSVNHistoryDataSupplier (com.kyj.fx.voeditor.visual.component.scm.FxSVNHistoryDataSupplier)1 ScmCommitComposite (com.kyj.fx.voeditor.visual.component.scm.ScmCommitComposite)1 SvnChagnedCodeComposite (com.kyj.fx.voeditor.visual.component.scm.SvnChagnedCodeComposite)1 JavaTextArea (com.kyj.fx.voeditor.visual.component.text.JavaTextArea)1 GargoyleException (com.kyj.fx.voeditor.visual.exceptions.GargoyleException)1 InstanceTypes (com.kyj.fx.voeditor.visual.framework.InstanceTypes)1 FXMLController (com.kyj.fx.voeditor.visual.framework.annotation.FXMLController)1 FxPostInitialize (com.kyj.fx.voeditor.visual.framework.annotation.FxPostInitialize)1 GargoyleBuilderFactory (com.kyj.fx.voeditor.visual.framework.builder.GargoyleBuilderFactory)1 GargoyleButtonBuilder (com.kyj.fx.voeditor.visual.framework.builder.GargoyleButtonBuilder)1 FxContextManager (com.kyj.fx.voeditor.visual.framework.contextmenu.FxContextManager)1 ToExcelFileFunction (com.kyj.fx.voeditor.visual.functions.ToExcelFileFunction)1 CloseableParent (com.kyj.fx.voeditor.visual.main.layout.CloseableParent)1 FxMemory (com.kyj.fx.voeditor.visual.momory.FxMemory)1 SharedMemory (com.kyj.fx.voeditor.visual.momory.SharedMemory)1