B4J Question Printing to USB Label printer

Declan

Well-Known Member
Licensed User
Longtime User
I am using the jFX8Print Library Version 0.7
I am using a Xprinter XP-365B Thermal Label printer.
My Label size is 39mm(W) X 18mm(H)
On my Windows 10 PC, the Xprinter is set as "Default Printer"
The Printer Preferences has only 1 paper size set - 39mm(W) X 18mm(H)
The printer works great and I have tested it with the Xprinter Test software.
My B4J app has a Panel "pnlQR" which has 2 X imageviews and 2 X labels.
The imageviews display the QR Barcodes, the labels display a text.
I use:
B4X:
    Dim m As Image = MainForm.RootPane.Snapshot
    Dim cv As Canvas
    cv.Initialize("")
    cv.DrawImage(m,0,0,100,60)
to take a snapshot of pnlQR.
I must then send this to the printer with btnPrint_Click (No Dialogs):
B4X:
Private Sub btnPrint_Click
    Dim m As Image = MainForm.RootPane.Snapshot
    Dim cv As Canvas
    cv.Initialize("")
    cv.DrawImage(m,0,0,100,60)
  
    Dim P As Printer = Printer_Static.GetDefaultPrinter
'    Dim P As Printer = GetPrinter("Xprinter XP-365B")
    Dim PA As PrinterAttributes = P.GetPrinterAttributes
  
    Dim p_paper As Paper = PA.GetDefaultPaper
    Dim PJ As PrinterJob = PrinterJob_Static.CreatePrinterJob2(p)
    pl = p.CreatePageLayout(p_paper,"PORTRAIT",1,1,1,1) ' You should change orientation and margin If Neccessary
  
    PJ.GetJobSettings.SetCopies(1)
    PJ.GetJobSettings.SetPageLayout(pl)
    PJ.GetJobSettings.SetPrintQuality("HIGH")
    PJ.GetJobSettings.SetJobName("QR_PRINTER")
  
    Dim PJ As PrinterJob = PrinterJob_Static.CreatePrinterJob2(P)
    PJ.PrintPage(pnlQR)
    PJ.EndJob
  
End Sub

However, I have the following error:
B4X:
Waiting for debugger to connect...
Program started.
Error occurred on line: 35 (Paper)
java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:132)
    at b4j.example.printer._createpagelayout(printer.java:80)
    at b4j.example.main._btnprint_click(main.java:143)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:629)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:234)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:109)
    at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
    at anywheresoftware.b4a.BA$1.run(BA.java:234)
    at com.sun.javafx.application.PlatformImpl.lambda$null$5(PlatformImpl.java:295)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$6(PlatformImpl.java:294)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.lambda$null$4(WinApplication.java:186)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NullPointerException
    at com.sun.prism.j2d.print.J2DPrinter.getMediaSizeName(J2DPrinter.java:832)
    at com.sun.prism.j2d.print.J2DPrinter.printableArea(J2DPrinter.java:848)
    at javafx.print.Printer.createPageLayout(Printer.java:349)
    ... 28 more
Picked up _JAVA_OPTIONS: -Djava.net.preferIPv4Stack=true
If I send this to the printer with btnReprint_Click (With Dialogs):
B4X:
Private Sub btnReprint_Click
    Dim m As Image = MainForm.RootPane.Snapshot
    Dim cv As Canvas
    cv.Initialize("")
    cv.DrawImage(m,0,0,100,60)

    Dim P As Printer = Printer_Static.GetDefaultPrinter
'    Dim P As Printer = GetPrinter("Xprinter XP-365B")
    Dim PJ As PrinterJob = PrinterJob_Static.CreatePrinterJob2(P)
    PJ.ShowPageSetupDialog(Null)
    PJ.ShowPrintDialog(Null)
    PJ.PrintPage(pnlQR)
    PJ.EndJob

End Sub
I receive the following error:
B4X:
Waiting for debugger to connect...
Program started.
Error occurred on line: 67 (PrinterJob)
java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:132)
    at b4j.example.printerjob._showpagesetupdialog(printerjob.java:105)
    at b4j.example.main._btnreprint_click(main.java:200)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:629)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:234)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:109)
    at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
    at anywheresoftware.b4a.BA$1.run(BA.java:234)
    at com.sun.javafx.application.PlatformImpl.lambda$null$5(PlatformImpl.java:295)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$6(PlatformImpl.java:294)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.lambda$null$4(WinApplication.java:186)
    at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.NullPointerException
    at com.sun.prism.j2d.print.J2DPrinter.getMediaSizeName(J2DPrinter.java:832)
    at com.sun.prism.j2d.print.J2DPrinter.printableArea(J2DPrinter.java:848)
    at javafx.print.Printer.createPageLayout(Printer.java:249)
    at javafx.print.Printer.getDefaultPageLayout(Printer.java:221)
    at javafx.print.JobSettings.pageLayoutProperty(JobSettings.java:1097)
    at javafx.print.JobSettings.getPageLayout(JobSettings.java:1133)
    at com.sun.prism.j2d.print.J2DPrinterJob.syncPageLayout(J2DPrinterJob.java:615)
    at com.sun.prism.j2d.print.J2DPrinterJob.syncSettingsToAttributes(J2DPrinterJob.java:564)
    at com.sun.prism.j2d.print.J2DPrinterJob.showPageDialog(J2DPrinterJob.java:240)
    at javafx.print.PrinterJob.showPageSetupDialog(PrinterJob.java:343)
    ... 28 more
Picked up _JAVA_OPTIONS: -Djava.net.preferIPv4Stack=true
I have attached my app ZIP file.
 

Attachments

  • Printer.zip
    15 KB · Views: 205
Last edited:

Xfood

Expert
Licensed User
Many, many thanks.
I send the following from the command prompt:
C:\>NET USE COM1://MSI/QR/persistent:yes
But get the following error:
System error 67 has occurred.
The network name cannot be found.

I have tried numerous web solutions to this, but all in vain.
in your example there are no spaces,
however I would use a com other than 1 type com 8
NET USE COM1: //MSI/QR /persistent:yes

NET USE COM8: //MSI/QR /persistent:yes
 
Upvote 0

MicroDrie

Well-Known Member
Licensed User
System error 67 has occurred.
This error 67 is the result of a Network Name that Cannot Be Found.
 
Upvote 0

Xfood

Expert
Licensed User
if it doesn't put spaces, it won't find the correct network name.


then we clearly assume that the network name set by this user is correct, and that the printer share name is correct as in the example just shown
 
Upvote 0

Declan

Well-Known Member
Licensed User
Longtime User
if it doesn't put spaces, it won't find the correct network name.


then we clearly assume that the network name set by this user is correct, and that the printer share name is correct as in the example just shown
I now receive the following error:
B4X:
C:\>NET USE COM8: //MSI/QR /persistent:yes
The option //MSI/QR is unknown.

The syntax of this command is:

NET USE
[devicename | *] [\\computername\sharename[\volume] [password | *]]
        [/USER:[domainname\]username]
        [/USER:[dotted domain name\]username]
        [/USER:[username@dotted domain name]
        [/SMARTCARD]
        [/SAVECRED]
        [/REQUIREINTEGRITY]
        [/REQUIREPRIVACY]
        [/WRITETHROUGH]
        [[/DELETE] | [/PERSISTENT:{YES | NO}]]

NET USE {devicename | *} [password | *] /HOME

NET USE [/PERSISTENT:{YES | NO}]

More help is available by typing NET HELPMSG 3506.


C:\>
My Network Name is:
NetworkName.png
 
Upvote 0

Xfood

Expert
Licensed User
I now receive the following error:
B4X:
C:\>NET USE COM8: //MSI/QR /persistent:yes
The option //MSI/QR is unknown.

The syntax of this command is:

NET USE
[devicename | *] [\\computername\sharename[\volume] [password | *]]
        [/USER:[domainname\]username]
        [/USER:[dotted domain name\]username]
        [/USER:[username@dotted domain name]
        [/SMARTCARD]
        [/SAVECRED]
        [/REQUIREINTEGRITY]
        [/REQUIREPRIVACY]
        [/WRITETHROUGH]
        [[/DELETE] | [/PERSISTENT:{YES | NO}]]

NET USE {devicename | *} [password | *] /HOME

NET USE [/PERSISTENT:{YES | NO}]

More help is available by typing NET HELPMSG 3506.


C:\>
My Network Name is:
View attachment 129217

you have to share the printer and then recall it with the command

NET USE COM8: //MY_PC_NAME/MY_SHARED_PRINTER_NAME /persistent:yes
 
Upvote 0

Declan

Well-Known Member
Licensed User
Longtime User
you have to share the printer and then recall it with the command

NET USE COM8: //MY_PC_NAME/MY_SHARED_PRINTER_NAME /persistent:yes
I now receive the following error:
B4X:
C:\>NET USE COM8: //MSI/QR /persistent:yes
The option //MSI/QR is unknown.

The syntax of this command is:

NET USE
[devicename | *] [\\computername\sharename[\volume] [password | *]]
        [/USER:[domainname\]username]
        [/USER:[dotted domain name\]username]
        [/USER:[username@dotted domain name]
        [/SMARTCARD]
        [/SAVECRED]
        [/REQUIREINTEGRITY]
        [/REQUIREPRIVACY]
        [/WRITETHROUGH]
        [[/DELETE] | [/PERSISTENT:{YES | NO}]]

NET USE {devicename | *} [password | *] /HOME

NET USE [/PERSISTENT:{YES | NO}]

More help is available by typing NET HELPMSG 3506.


C:\>

Printer is Shared:
Printer-Sharing.png
 
Upvote 0

Xfood

Expert
Licensed User
as it says @MicroDrie
This error 67 is the result of a Network Name that Cannot Be Found.

is your pc name correct? can't find the network you are referring to, try replacing the pc name with \\ 127.0.0.1 \ QR

Net use com8: \\127.0.0.1\QR /persistent:yes
 
Upvote 0

MicroDrie

Well-Known Member
Licensed User
Things to check for this error The network resource type is not correct. [ERROR_BAD_DEV_TYPE (0x42)]:
  1. Do you open de CMD DOS box as administrator by search for CMD and then right click and choose run as administrator?
  2. Is the DOS BOX opened in an virtual machine?
  3. Do you have delete the old added printer connection (because it will be there by the /persistent:yes previous used command)?
  4. Is you PC name MSI?
  5. Can see the printer name QR?
update: added more questions
 
Last edited:
Upvote 0

Xfood

Expert
Licensed User
I did some tests, and even me in com8 or com1 does not work for me,
by type of network resource not allowed,
instead with LPT1 it works, but I don't think it's your solution
1652592516641.png
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
I did some tests, and even me in com8 or com1 does not work for me,
by type of network resource not allowed,
instead with LPT1 it works, but I don't think it's your solution
View attachment 129241
I can't read what's written after user, the image looks blurry
 
Upvote 0

keirS

Well-Known Member
Licensed User
Longtime User
Strange. This definitely used to work as it was a work round to use USB receipt printers with old POS software which could only write to COM ports.
 
Upvote 0

Declan

Well-Known Member
Licensed User
Longtime User
Strange, I still have the problem of setting a COM port.
If I use the following to LPT1, it works:
B4X:
C:\Users\Robert>NET USE LPT1: \\192.168.3.200\QR /persistent:yes
The command completed successfully.
But if I use the following to any COM port, it does not work:
B4X:
C:\Users\Robert>NET USE COM5: \\192.168.3.200\QR /persistent:yes
System error 66 has occurred.

The network resource type is not correct.
 
Upvote 0

MicroDrie

Well-Known Member
Licensed User
In Post 1, Declan writes:

I am using the jFX8Print Library Version 0.7
I am using a Xprinter XP-365B Thermal Label printer.
My Label size is 39mm(W) X 18mm(H)
On my Windows 10 PC, the Xprinter is set as "Default Printer"
The Printer Preferences has only 1 paper size set - 39mm(W) X 18mm(H)
The printer works great and I have tested it with the Xprinter Test software.
Based on the last line, we have to conclude that there is nothing wrong with the communication between the Windows driver via the USB port to the printer.

Regardless of whether or not we are being able to successfully use the outdated DOS remap command in Declan's OS version, I suspect that Windows therefore does not allow connecting the printer already claimed by the printer driver directly with a B4J program.

So it doesn't seem at all that there is a connection problem between the PC and the connected printer. What remains then is a connection problem between the B4J program or incorrect operation use of the printer driver. To investigate the connection problem between B4J and the printer driver, you can use the program below:

Show all installed Windows Printer and default printer status:
Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
    Private NativeMe As JavaObject
End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.Show
    NativeMe = Me
    Dim s As String = NativeMe.RunMethod("Test", Null)
    Log(s)
    Dim s As String = NativeMe.RunMethod("ShowPrinters", Null)
    Log(s)
End Sub

#IF JAVA
import java.awt.print.*;
import javax.print.*;
import javax.print.attribute.*;
import java.text.*;
import javax.print.attribute.standard.*;

public static void ShowPrinters() {
    DocFlavor myFormat = DocFlavor.SERVICE_FORMATTED.PRINTABLE;
    PrintRequestAttributeSet aset = new HashPrintRequestAttributeSet();
    PrintService[] services =PrintServiceLookup.lookupPrintServices(myFormat, aset);
    System.out.println("The following printers are available");
    for (int i=0;i<services.length;i++) {
      System.out.println("  service name: "+services[i].getName());
    }
    
    //  get the default printer status
    System.out.println("Get the default printer status");
    PrintService service = PrintServiceLookup.lookupDefaultPrintService();
        AttributeSet attributeSet = service.getAttributes();
        for (Attribute a : attributeSet.toArray()) {
             System.out.println(a.getName() + ": " + attributeSet.get(a.getClass()).toString());
    }
    
    // offer the user to modify the status by calling
    PrinterJob pj = PrinterJob.getPrinterJob();
    pj.printDialog();
    
    /** working without meaningfull info
    PrintService printServices = PrintServiceLookup.lookupDefaultPrintService();
    DocFlavor[] docF = printServices.getSupportedDocFlavors();
    for(int i = 0; i < docF.length; i++){
           System.out.println(docF[i].getMimeType());
    }
    */
  }     
#End If

In my case the log shows all my installed printers:
Waiting for debugger to connect...
Program started.
Hello world!
The following printers are available
service name: Send To OneNote 16
service name: OneNote for Windows 10
service name: NPIDB7924 (HP LaserJet MFP M28w)
service name: Microsoft XPS Document Writer
service name: Microsoft Print to PDF
service name: Fax
service name: CutePDF Writer
Get the default printer status
printer-name: NPIDB7924 (HP LaserJet MFP M28w)
printer-is-accepting-jobs: accepting-jobs
queued-job-count: 0
color-supported: not-supported
null
After this is printed, the Windows printer driver is showed, it proofs that there are no rights issues.
However, I am not a JAVA expert, but I cannot manage to send something to the default printer with the 64 bit 9.50 version of B4J with inline java code due to the error message “Non-static variable cannot be referenced from a static context”not even with code that the author says will prevent that error message.
 
Upvote 0

Declan

Well-Known Member
Licensed User
Longtime User
@MicroDrie
Running your code I get the same result - all my printers are display in the Log:
B4X:
Waiting for debugger to connect...
Program started.
The following printers are available
  service name: Xprinter XP-365B
  service name: Solid Edge Velocity PS Printer 2.0
  service name: Samsung M2020 Series (USB001)(0)
  service name: Samsung M2020 Series (USB001)
  service name: OneNote for Windows 10
  service name: OneNote (Desktop)
  service name: Microsoft XPS Document Writer
  service name: Microsoft Print to PDF
  service name: HP DJ 3830 series
  service name: Fax
Get the default printer status
printer-name: Xprinter XP-365B
color-supported: not-supported
printer-is-accepting-jobs: accepting-jobs
queued-job-count: 0
null
However, I had to comment the following out:
B4X:
'    Dim s As String = NativeMe.RunMethod("Test", Null)
'    Log(s)
If not commented out, it throws the following error:
B4X:
Waiting for debugger to connect...
Program started.
Error occurred on line: 11 (Main)
java.lang.RuntimeException: Method: Test not found in: b4j.example.main
    at anywheresoftware.b4j.object.JavaObject$MethodCache.getMethod(JavaObject.java:363)
    at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:120)
    at b4j.example.main._appstart(main.java:84)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:629)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:237)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:109)
    at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:96)
    at b4j.example.main.start(main.java:43)
    at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$8(LauncherImpl.java:863)
    at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$7(PlatformImpl.java:326)
    at com.sun.javafx.application.PlatformImpl.lambda$null$5(PlatformImpl.java:295)
    at java.security.AccessController.doPrivileged(Native Method)
    at com.sun.javafx.application.PlatformImpl.lambda$runLater$6(PlatformImpl.java:294)
    at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
    at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
    at com.sun.glass.ui.win.WinApplication.lambda$null$4(WinApplication.java:186)
    at java.lang.Thread.run(Thread.java:748)
Picked up _JAVA_OPTIONS: -Djava.net.preferIPv4Stack=true
 
Upvote 0

MicroDrie

Well-Known Member
Licensed User
Forget the test error, I have left out the code for test routine.
Your B4J can see the Windows printers and your Window drivers can see the printer so we have to look to the problems in the communication between B4J code and the Windows default printer driver.

A printer driver support the basic function of printing a text line. Lets start simple and forget for the moment the complex printing of any thing more the one line of text to see if there is communication between B4J and the Window printer driver. Install both the B4j Print JavaFX8 library and the test program. Run the test program to see if the printer can print the text Test on paper. If that works then you know that you can reach your USB printer with Steve's B4j Print JavaFX8 library. First question: does your printer print the test line on the paper?

If it is possible to print the Test line on your USB printer we come to next step which is more complicated because we must send all kind of special commands to the printer. To know those special commands we need to look in the documentation of your printer. Second question do you have a link to your printer documentation which have the so-called printer codes?
 
Upvote 0

Declan

Well-Known Member
Licensed User
Longtime User
Install both the B4j Print JavaFX8 library and the test program
Ok,
When I run the test program "Printer-B4J":
B4X:
#Region  Project Attributes
    #MainFormWidth: 600
    #MainFormHeight: 400
    #LibraryAuthor:Steve Laming
    #LibraryName: jFX8Print
    #LibraryVersion: 0.7
   
#End Region

Sub Process_Globals
    Private fx As JFX
    Private MainForm As Form
    Private lblTest As Label
End Sub

Sub AppStart (Form1 As Form, Args() As String)
    MainForm = Form1
    MainForm.RootPane.LoadLayout("1") 'Load the layout file.
    MainForm.Show
   
        'Print with dialogs
    Dim PJ As PrinterJob = PrinterJob_Static.CreatePrinterJob
    PJ.ShowPageSetupDialog(Null)
    PJ.ShowPrintDialog(Null)
    PJ.PrintPage(ScaleOutput(PJ.GetPrinter,MainForm.RootPane))
    PJ.EndJob
   
'    'Print without dialogs
'  
'    Dim P As Printer = Printer_Static.GetDefaultPrinter
'    Dim PJ As PrinterJob = PrinterJob_Static.CreatePrinterJob2(P)
'    PJ.PrintPage(lblTest)
'    PJ.EndJob
   
End Sub
Sub ScaleOutput(P As Printer,N As Node) As Node
    Dim PL As PageLayout = P.GetDefaultPageLayout
    Dim ScaleX,ScaleY As Double
    Dim NJO As JavaObject = N
    Dim JO As JavaObject = N
    ScaleX = PL.GetPrintableWidth / JO.RunMethodJO("getBoundsInParent",Null).RunMethod("getWidth",Null)
    ScaleY = PL.GetPrintableHeight / JO.RunMethodJO("getBoundsInParent",Null).RunMethod("getHeight",Null)
    Dim SJO As JavaObject
    SJO.InitializeNewInstance("javafx.scene.transform.Scale",Array(ScaleX,ScaleY))
    NJO.RunMethodJO("getTransforms",Null).RunMethod("add",Array(SJO))
    Return NJO
End Sub
It does not print "Test" text.
Instead, the printer outputs:
Print.jpg

For initial testing, I am running a roll of continuous thermal paper.
 
Upvote 0
Top