B4J Library B4j Print JavaFX8

skeedsr

Member
Hy and thank you for this library.

i would like to ask you if i can print some part of my form..

example, if i try to stamp a list view, work well

lvoreasso as listview

PJ.PrintPage2(pl,lvoreasso)

but i would like to print two or three listview or some part of my form..

i try..
PJ.PrintPage2(pl,lvoreasso&lvcommesse) but not work..

yhanks!

Livio
 

Tayfur

Well-Known Member
Licensed User
Longtime User
I use the underlying code to print the item (PANE1) on the form.
The position of PANE1 in the form is Left: 140 Top: 100.
I send you the results from the printer in attachment.
I wanted PANE1 to be in the L: 0 / T: 0 position on A4 page. But it printed it in the same position (L: 140 / T: 100) as like in mainforms.

How is fix it witt setting of printer lib.

B4X:
Sub Button1_MouseClicked (EventData As MouseEvent)
'    Dim P As Printer = Printer_Static.GetDefaultPrinter
'    Dim PJ As PrinterJob = PrinterJob_Static.CreatePrinterJob2(P)
'    PJ.PrintPage(Pane1)
'    PJ.EndJob
    Log("X:"&Pane1.Left&" Y:"&Pane1.top)
    Dim PJ As PrinterJob = PrinterJob_Static.CreatePrinterJob
    PJ.ShowPageSetupDialog(Null)
    PJ.ShowPrintDialog(Null)
  
    PJ.PrintPage(Pane1)
    PJ.EndJob
  
End Sub
 

Attachments

  • JavaFX Print Job.pdf
    9 KB · Views: 648

stevel05

Expert
Licensed User
Longtime User
Can you upload the project?
 

stevel05

Expert
Licensed User
Longtime User
As it's printing the pane, it is positioned according to the layout of that pane. You will need to temporarily set the top and left to 0, then print it, you can hide it under a progress screen so the user doesn't see it move. Or duplicate the pane in another window off the screen.
 

Tayfur

Well-Known Member
Licensed User
Longtime User


thanks for help;
I must a create new form and add in pane (layout must be set 0;0).

is it correct?
 

stevel05

Expert
Licensed User
Longtime User
Yes, or temporarily move it in the existing pane.
 

stevel05

Expert
Licensed User
Longtime User
This won't print an excel document. Just the image of it that is displayed in a Node.
 

jcohedman

Member
Licensed User
Longtime User
I'm using this to print in a Epson LX-300+, and it functions!

but... the question is: how to change the font size?
can anybody help me?

thanks...
 

stevel05

Expert
Licensed User
Longtime User
It should print the fonts relative to the content of the displayed node. I say relative because it would be a different size for example if you use the scale sub, or select the expand/reduce page size in the print driver.

So you need to change the font on the Label or Textarea/field (s) that are contained in the node you are printing.
 

AHilton

Active Member
Licensed User
Longtime User
Has anyone managed to get this to work with a label printer? I am trying to get a simple, short label node to print on a Brother QL-720NW printer and it's giving me an error "java.lang.illegalArgumentException: Bad margins" or "Illegal Parameters" regardless of what I try.
 

Swissmade

Well-Known Member
Licensed User
Longtime User
Has anyone managed to get this to work with a label printer?
Yes I have
This error is from the printer. You have to create a paper for your label size and select this. Margin very is important
 

AHilton

Active Member
Licensed User
Longtime User
Do you see anything glaringly wrong here ...

B4X:
    Dim PR As Printer = Printer_Static.GetDefaultPrinter
    Dim PJ As PrinterJob = PrinterJob_Static.CreatePrinterJob2(PR)
    For Each SP As JavaObject In pr.GetPrinterAttributes.GetSupportedPapers
        Dim PA As Paper
        PA.SetObject(SP)
        If PA.GetName.Contains("1.1") And PA.GetName.Contains("3.5") Then
            Dim r As Reflector
            R.Target = SP
            R.SetField2("height", 90)
            R.SetField2("width", 29)
            PA.SetObject(SP)
            Exit
        End If
    Next
    Dim PL As PageLayout = pr.CreatePageLayout2(PA, PageOrientation_Static.LANDSCAPE, "HARDWARE_MINIMUM")
    PJ.PrintPage2(PL, Label)
    PJ.EndJob
 

Swissmade

Well-Known Member
Licensed User
Longtime User
This was also my mistake
You have to set a page in your Printer and select this page.
What you are doing is, you create a page but you don't tell this your printer.
Add a new page to your Printer
 

AHilton

Active Member
Licensed User
Longtime User
This was also my mistake
You have to set a page in your Printer and select this page.
What you are doing is, you create a page but you don't tell this your printer.
Add a new page to your Printer


And what is the command to tell my printer that?
 

Swissmade

Well-Known Member
Licensed User
Longtime User
And what is the command to tell my printer that?
I have create this in Windows.
Just add the page to the Printer.
I don't know your printer how this has to be done.
This is the code I print Labels with QRCode
The Printer and Paper size from the Printer I have in a list.
B4X:
Private Sub PrintBarcode()
Try
    JobPrint = False
    Dim img As Image
    img.Initialize(File.DirAssets, "LogoEntrada.png")
    imgBrand.SetImage(img)
    lblText.Text = Main.txtBarCodeText ' "Some Text"

    img.Initialize(Main.DirApp, "Barcodebuild.png")
    imgBarcode.SetImage(img)
   
    lblBarcodeText.Text = txtTextForBarcode.Text
    PrintForm.Show
    Dim PPX As Paper
    PPX.Initialize()
    Dim PC As Printer
    PC.Initialize()
    Dim PL As PageLayout
    PL.Initialize()
'Get the Papersize   
    Dim Width As Double
    Dim Height As Double
    Dim PP As JavaObject
    Dim r As Reflector
Dim SetPageFormat As Boolean = True 'False
'Get the Printer from List
PC = PrinterList.Get(lstPrinters.SelectedIndex)

PP = PrintersPaperSizeList.Get(lstPrintersPaperSize.SelectedIndex)
r.Target = PP
Width = r.GetField("width")
Height = r.GetField("height")

If SetPageFormat = True Then
    PPX.SetObject(PP)
    PL = PC.CreatePageLayout(PPX, PageOrientation_Static.PORTRAIT,1, 1, 1, 1)
End If
    PJ = PrinterJob_Static.CreatePrinterJob2(PC)


    If HavePrinter.IsInitialized = False Then
        HavePrinter.Initialize()
    End If    
'    'Print without dialogs

If SetPageFormat = True Then
    PJ.PrintPage2(PL, PrintForm.RootPane)
Else
    PJ.PrintPage(PrintForm.RootPane)
End If
    PJ.EndJob
    PrintForm.Close
    JobPrint = True
Catch
    Functions.ShowLog("Error PrintForm modBarcode", True, False, LastException.Message)
End Try
End Sub
 

AHilton

Active Member
Licensed User
Longtime User
Which label printer are you using, swissmade?

This simply will not work with the Brother QL-xxx label printers. I've tried everything getting JavaFX8 to print to them and can't waste anymore time.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…