B4J Question Print Size JavaFX8

Blueforcer

Well-Known Member
Licensed User
I want to print the whole RootPane.
But it prints the pane too large so the half is cut away.
It is possible to resize the print to fit to the paper automatically?
 

Informatix

Expert
Licensed User
Here's what I use:
B4X:
Dim PJ As PrinterJob = PrinterJob_Static.CreatePrinterJob
PJ.ShowPageSetupDialog(Null)
PJ.ShowPrintDialog(Null)
Dim ScaleX As Double = PJ.GetJobSettings.GetPageLayout.GetPrintableWidth / InfoForm.RootPane.Width
Dim ScaleY As Double = PJ.GetJobSettings.GetPageLayout.GetPrintableHeight / InfoForm.RootPane.Height
Dim Scale As Double = Min(ScaleX, ScaleY)
Dim SJO As JavaObject
SJO.InitializeNewInstance("javafx.scene.transform.Scale", Array(Scale, Scale))
Dim NJO As JavaObject = InfoForm.RootPane
NJO.RunMethodJO("getTransforms", Null).RunMethod("add", Array(SJO))
PJ.PrintPage(InfoForm.RootPane)
PJ.EndJob
 
Upvote 0

stevel05

Expert
Licensed User
If you are using B4j Print JavaFX8 the demo app as a subroutine to do that. Or you could use the options in the print dialog.

Edit: or Informatix's code. Just beat me. :)
 
Upvote 0
Top