D Declan Well-Known Member Licensed User Longtime User Apr 24, 2022 #1 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 Printer.zip 15 KB · Views: 737 Last edited: Apr 24, 2022
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.
stevel05 Expert Licensed User Longtime User Apr 24, 2022 #2 It looks like there may not be a default paper for the printer. what do you get if you Log(PA.GetDefaultPaper.GetObject) ? you can also get a list of the supported papers using PrinterAttributes.GetSupportedPapers. Upvote 0
It looks like there may not be a default paper for the printer. what do you get if you Log(PA.GetDefaultPaper.GetObject) ? you can also get a list of the supported papers using PrinterAttributes.GetSupportedPapers.
D Declan Well-Known Member Licensed User Longtime User Apr 25, 2022 #3 stevel05 said: what do you get if you Log(PA.GetDefaultPaper.GetObject) ? Click to expand... I get the following: B4X: (Paper) Paper: USER size=78.7x101.6 MM Then the Error: B4X: Waiting for debugger to connect... Program started. (Paper) Paper: USER size=78.7x101.6 MM Error occurred on line: 54 (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:207) 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.IllegalArgumentException: Bad margins at javafx.print.PageLayout.<init>(PageLayout.java:109) at javafx.print.Printer.createPageLayout(Printer.java:307) 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 This is a screenshot of the printer paper setups: "QR-39X18" is the paper I require. stevel05 said: you can also get a list of the supported papers using PrinterAttributes.GetSupportedPapers. Click to expand... I get: B4X: (ArrayList) [Paper: 2 x 4 size=53.3x101.6 MM, Paper: USER size=78.7x101.6 MM] My paper size "QR-39X18" does not show. I still do not get the printer Dialogs: B4X: Waiting for debugger to connect... Program started. (Paper) Paper: USER size=78.7x101.6 MM (ArrayList) [Paper: 2 x 4 size=53.3x101.6 MM, Paper: USER size=78.7x101.6 MM] Error occurred on line: 54 (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:210) 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.IllegalArgumentException: Bad margins at javafx.print.PageLayout.<init>(PageLayout.java:109) at javafx.print.Printer.createPageLayout(Printer.java:307) 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 Upvote 0
stevel05 said: what do you get if you Log(PA.GetDefaultPaper.GetObject) ? Click to expand... I get the following: B4X: (Paper) Paper: USER size=78.7x101.6 MM Then the Error: B4X: Waiting for debugger to connect... Program started. (Paper) Paper: USER size=78.7x101.6 MM Error occurred on line: 54 (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:207) 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.IllegalArgumentException: Bad margins at javafx.print.PageLayout.<init>(PageLayout.java:109) at javafx.print.Printer.createPageLayout(Printer.java:307) 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 This is a screenshot of the printer paper setups: "QR-39X18" is the paper I require. stevel05 said: you can also get a list of the supported papers using PrinterAttributes.GetSupportedPapers. Click to expand... I get: B4X: (ArrayList) [Paper: 2 x 4 size=53.3x101.6 MM, Paper: USER size=78.7x101.6 MM] My paper size "QR-39X18" does not show. I still do not get the printer Dialogs: B4X: Waiting for debugger to connect... Program started. (Paper) Paper: USER size=78.7x101.6 MM (ArrayList) [Paper: 2 x 4 size=53.3x101.6 MM, Paper: USER size=78.7x101.6 MM] Error occurred on line: 54 (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:210) 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.IllegalArgumentException: Bad margins at javafx.print.PageLayout.<init>(PageLayout.java:109) at javafx.print.Printer.createPageLayout(Printer.java:307) 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
stevel05 Expert Licensed User Longtime User Apr 25, 2022 #4 B4X: pl = p.CreatePageLayout(p_paper,"PORTRAIT",1,1,1,1) ' You should change orientation and margin If Neccessary Caused by: java.lang.IllegalArgumentException: Bad margins It looks like it can't handle margins of size 1. Try increasing it the error should disappear. Upvote 0
B4X: pl = p.CreatePageLayout(p_paper,"PORTRAIT",1,1,1,1) ' You should change orientation and margin If Neccessary Caused by: java.lang.IllegalArgumentException: Bad margins It looks like it can't handle margins of size 1. Try increasing it the error should disappear.
MicroDrie Well-Known Member Licensed User Longtime User May 11, 2022 #5 A litle late but your XP-365B printer spec is: high-capacity for paper, large diameter 82 mm can be put on label Click to expand... And your working paper size is: QR-39X18 (39.0 mm x 18.0 mm Click to expand... Then total margin = 82 - 39 mm = 42 mm. Try to fool the printer by leaving a Left and Right Margin of say 2 mm for the right half that is not to be printed, leaving for the right side 82 mm physical width - (2 mm + 37 mm) = 39 mm label print space = 43 mm for the Right Margin to be copied. This should leave a 2mm margin on both sides of the label. When you align the label in the middle in the printer, you must use 43/2 as margin on both sides. Upvote 0
A litle late but your XP-365B printer spec is: high-capacity for paper, large diameter 82 mm can be put on label Click to expand... And your working paper size is: QR-39X18 (39.0 mm x 18.0 mm Click to expand... Then total margin = 82 - 39 mm = 42 mm. Try to fool the printer by leaving a Left and Right Margin of say 2 mm for the right half that is not to be printed, leaving for the right side 82 mm physical width - (2 mm + 37 mm) = 39 mm label print space = 43 mm for the Right Margin to be copied. This should leave a 2mm margin on both sides of the label. When you align the label in the middle in the printer, you must use 43/2 as margin on both sides.
D Declan Well-Known Member Licensed User Longtime User May 12, 2022 #6 MicroDrie said: When you align the label in the middle in the printer, you must use 43/2 as margin on both sides Click to expand... My printer does not allow for the label to be loaded in the middle of the printer. I am only able to load the label on the left side of the printer - this being the right side of the label in the travel direction. Upvote 0
MicroDrie said: When you align the label in the middle in the printer, you must use 43/2 as margin on both sides Click to expand... My printer does not allow for the label to be loaded in the middle of the printer. I am only able to load the label on the left side of the printer - this being the right side of the label in the travel direction.
MicroDrie Well-Known Member Licensed User Longtime User May 12, 2022 #7 Thats fine that the the label is loaded on the left side of the printer. Then you can use my program code which suppose to prints its own nothing outside the label width. I hope it works. I'm curious. Upvote 0
Thats fine that the the label is loaded on the left side of the printer. Then you can use my program code which suppose to prints its own nothing outside the label width. I hope it works. I'm curious.
D Declan Well-Known Member Licensed User Longtime User May 12, 2022 #8 Irrespective of how I change the margins with: B4X: pl = p.CreatePageLayout(p_paper,"PORTRAIT",40,0,0,0) It does not alter the print position. I have tried numerous permutations of the Left and Right margins. Upvote 0
Irrespective of how I change the margins with: B4X: pl = p.CreatePageLayout(p_paper,"PORTRAIT",40,0,0,0) It does not alter the print position. I have tried numerous permutations of the Left and Right margins.
MicroDrie Well-Known Member Licensed User Longtime User May 12, 2022 #9 I was probably unclear, but a Left Margin 2 mm, a Right Margin 43 mm gives a label width of 37 mm with paper on the left side of de printer with 2 mm margin on both sizes of the label. Upvote 0
I was probably unclear, but a Left Margin 2 mm, a Right Margin 43 mm gives a label width of 37 mm with paper on the left side of de printer with 2 mm margin on both sizes of the label.
K keirS Well-Known Member Licensed User Longtime User May 12, 2022 #10 Not sure why you are trying to use the Windows driver. It's a label printer so has the ability to print QRCodes inbuilt. Why not just send the commands to printer to print the QR Codes? Your printer emulates TSPL which is the TSC / Kroy Printer language and that has a QRCODE command, You can find the language manual here: https://fs.tscprinters.com/system/files/tspl_tspl2_programming_2022_4_11.pdf Upvote 0
Not sure why you are trying to use the Windows driver. It's a label printer so has the ability to print QRCodes inbuilt. Why not just send the commands to printer to print the QR Codes? Your printer emulates TSPL which is the TSC / Kroy Printer language and that has a QRCODE command, You can find the language manual here: https://fs.tscprinters.com/system/files/tspl_tspl2_programming_2022_4_11.pdf
D Declan Well-Known Member Licensed User Longtime User May 13, 2022 #11 keirS said: Not sure why you are trying to use the Windows driver. Click to expand... I am using the Seagull Scientific driver, as supplied by the Printer manufacturer. keirS said: It's a label printer so has the ability to print QRCodes inbuilt. Why not just send the commands to printer to print the QR Codes? Your printer emulates TSPL which is the TSC / Kroy Printer language and that has a QRCODE command, You can find the language manual here: Click to expand... @keirS Do you possibly have an example code? The manual is very extensive and I shudder at the learning-curve required. Upvote 0
keirS said: Not sure why you are trying to use the Windows driver. Click to expand... I am using the Seagull Scientific driver, as supplied by the Printer manufacturer. keirS said: It's a label printer so has the ability to print QRCodes inbuilt. Why not just send the commands to printer to print the QR Codes? Your printer emulates TSPL which is the TSC / Kroy Printer language and that has a QRCODE command, You can find the language manual here: Click to expand... @keirS Do you possibly have an example code? The manual is very extensive and I shudder at the learning-curve required.
D Declan Well-Known Member Licensed User Longtime User May 13, 2022 #12 MicroDrie said: I was probably unclear, but a Left Margin 2 mm, a Right Margin 43 mm gives a label width of 37 mm with paper on the left side of de printer with 2 mm margin on both sizes of the label. Click to expand... I have tried this: B4X: pl = p.CreatePageLayout(p_paper,"PORTRAIT",2,43,0,0) But as I mentioned before, it does not change the print position on the printer. Upvote 0
MicroDrie said: I was probably unclear, but a Left Margin 2 mm, a Right Margin 43 mm gives a label width of 37 mm with paper on the left side of de printer with 2 mm margin on both sizes of the label. Click to expand... I have tried this: B4X: pl = p.CreatePageLayout(p_paper,"PORTRAIT",2,43,0,0) But as I mentioned before, it does not change the print position on the printer.
K keirS Well-Known Member Licensed User Longtime User May 13, 2022 #13 Declan said: I am using the Seagull Scientific driver, as supplied by the Printer manufacturer. @keirS Do you possibly have an example code? The manual is very extensive and I shudder at the learning-curve required. Click to expand... Seagull drivers are of variable quality. I have had lots of experience with them and I would say they are generally rubbish. Anyway this should give you a good starting point. Code: SIZE 39.00 mm,18.00 mm DIRECTION 1,0 GAP 0 mm,0 mm CODEPAGE 850 CLS QRCODE 37,13,0,H,4,A,0,"QRCODE1" QRCODE 255,13,0,H,4,A,0,"QRCODE2" TEXT 37,172,"8",0,1,1,"QRCODE1" TEXT 255,172,"8",0,1,1,"QRCODE2" PRINT 1,1 Upvote 0
Declan said: I am using the Seagull Scientific driver, as supplied by the Printer manufacturer. @keirS Do you possibly have an example code? The manual is very extensive and I shudder at the learning-curve required. Click to expand... Seagull drivers are of variable quality. I have had lots of experience with them and I would say they are generally rubbish. Anyway this should give you a good starting point. Code: SIZE 39.00 mm,18.00 mm DIRECTION 1,0 GAP 0 mm,0 mm CODEPAGE 850 CLS QRCODE 37,13,0,H,4,A,0,"QRCODE1" QRCODE 255,13,0,H,4,A,0,"QRCODE2" TEXT 37,172,"8",0,1,1,"QRCODE1" TEXT 255,172,"8",0,1,1,"QRCODE2" PRINT 1,1
D Declan Well-Known Member Licensed User Longtime User May 13, 2022 #14 keirS said: Seagull drivers are of variable quality. I have had lots of experience with them and I would say they are generally rubbish. Anyway this should give you a good starting point. Code: SIZE 39.00 mm,18.00 mm DIRECTION 1,0 GAP 0 mm,0 mm CODEPAGE 850 CLS QRCODE 37,13,0,H,4,A,0,"QRCODE1" QRCODE 255,13,0,H,4,A,0,"QRCODE2" TEXT 37,172,"8",0,1,1,"QRCODE1" TEXT 255,172,"8",0,1,1,"QRCODE2" PRINT 1,1 Click to expand... Many thanks, Please bear with me... Should I remove the Seagull printer driver from my PC? Do I simply write the above code out to the printer on USB? What exactly is the procedure Upvote 0
keirS said: Seagull drivers are of variable quality. I have had lots of experience with them and I would say they are generally rubbish. Anyway this should give you a good starting point. Code: SIZE 39.00 mm,18.00 mm DIRECTION 1,0 GAP 0 mm,0 mm CODEPAGE 850 CLS QRCODE 37,13,0,H,4,A,0,"QRCODE1" QRCODE 255,13,0,H,4,A,0,"QRCODE2" TEXT 37,172,"8",0,1,1,"QRCODE1" TEXT 255,172,"8",0,1,1,"QRCODE2" PRINT 1,1 Click to expand... Many thanks, Please bear with me... Should I remove the Seagull printer driver from my PC? Do I simply write the above code out to the printer on USB? What exactly is the procedure
K keirS Well-Known Member Licensed User Longtime User May 13, 2022 #15 Easiest way is to use the Serial port on the printer instead of the USB port and use the serial library. If you only have a USB port on the printer then it's slightly more tricky but usually doable. Upvote 0
Easiest way is to use the Serial port on the printer instead of the USB port and use the serial library. If you only have a USB port on the printer then it's slightly more tricky but usually doable.
D Declan Well-Known Member Licensed User Longtime User May 13, 2022 #16 keirS said: If you only have a USB port on the printer then it's slightly more tricky but usually doable. Click to expand... Unfortunately my printer only has a USB port Upvote 0
keirS said: If you only have a USB port on the printer then it's slightly more tricky but usually doable. Click to expand... Unfortunately my printer only has a USB port
K keirS Well-Known Member Licensed User Longtime User May 13, 2022 #17 Ok what does the Ports tab of the Printer Properties say? Upvote 0
D Declan Well-Known Member Licensed User Longtime User May 13, 2022 #18 keirS said: Ok what does the Ports tab of the Printer Properties say? Click to expand... USB001 Virtual printer port for USB Xprinter XP-365B Upvote 0
keirS said: Ok what does the Ports tab of the Printer Properties say? Click to expand... USB001 Virtual printer port for USB Xprinter XP-365B
K keirS Well-Known Member Licensed User Longtime User May 13, 2022 #19 Ok you have COM ports which makes it easier. Add a new printer and select "Add a local printer or network printer with local settings" Select "Use an existing port" Select "USB001" from the dropdown Select "Generic" from the list of manufacturers and "Generic / Text Only" from the list of printers You can name the printer whatever you like Share the printer Next step is to redirect one of your COM ports to your label printer. Run a command prompt and use a command like this Code: NET USE COM1: //MY_PC_NAME/MY_SHARED_PRINTER_NAME /persistent:yes MY_PC_NAME = The name of your computer MY_SHARED_PRINTER_NAME = The name of the printer share you have created. You can use the jSerial library to write the label to the com port and that will write it to the printer. Upvote 0
Ok you have COM ports which makes it easier. Add a new printer and select "Add a local printer or network printer with local settings" Select "Use an existing port" Select "USB001" from the dropdown Select "Generic" from the list of manufacturers and "Generic / Text Only" from the list of printers You can name the printer whatever you like Share the printer Next step is to redirect one of your COM ports to your label printer. Run a command prompt and use a command like this Code: NET USE COM1: //MY_PC_NAME/MY_SHARED_PRINTER_NAME /persistent:yes MY_PC_NAME = The name of your computer MY_SHARED_PRINTER_NAME = The name of the printer share you have created. You can use the jSerial library to write the label to the com port and that will write it to the printer.
D Declan Well-Known Member Licensed User Longtime User May 14, 2022 #20 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. Upvote 0
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.