qzind / tray

Browser plugin for sending documents and raw commands to a printer or attached device.
https://qz.io
Other
824 stars 266 forks source link

NullPointerException when printing to Host (IP:Port) #1195

Closed MatteoFeltrin closed 8 months ago

MatteoFeltrin commented 8 months ago

I'm trying to print to a printer through it's IP and Port, but when i launch the print it throw a NullPointerException.

Setting all the "null" parameters inside options property doesn't help neither

OS: Windows QZTray Version: 2.2.2

If it can help, looking up at code, in PrintPDF.print() :177 method, job :184 is trying to be assigned the same service as output, but output.printer is NULL since the property is never assigned without having "name" in the configuration.

[DEBUG] 2023-10-20T12:27:04,707 @ qz.ws.PrintSocketClient:115
Message: {"call":"print","params":{"printer":{"host":"192.168.39.189","port":9100},"options":{"bounds":null,"colorType":"color","copies":1,"density":0,"duplex":false,"fallbackDensity":null,"interpolation":"bicubic","jobName":null,"legacy":false,"margins":0,"orientation":"portrait","paperThickness":null,"printerTray":null,"rasterize":"false","rotation":0,"scaleContent":"false","size":null,"units":"in","forceRaw":false,"encoding":null,"spool":null},"data":[{"type":"pdf","format":"base64","data":"A VERY LONG BASE64 ENCODED PDF FILE THAT I REMOVED FOR READING PURPORSES","timestamp":1697797624644,"uid":"qwpuev","position":{"x":1720,"y":696},"signAlgorithm":"SHA512"}
[TRACE] 2023-10-20T12:27:04,713 @ qz.ws.PrintSocketClient:160
Valid signature from company
[TRACE] 2023-10-20T12:27:04,714 @ qz.utils.PrintingUtilities:135
Waiting for processor, 0/16 already in use
[DEBUG] 2023-10-20T12:27:04,716 @ qz.utils.PrintingUtilities:195
Using qz.printer.action.PrintPDF to print
[WARN] 2023-10-20T12:27:04,716 @ qz.printer.PrintOptions:17
Cannot read null as a double for fallbackDensity, using default
[DEBUG] 2023-10-20T12:27:04,718 @ qz.printer.action.PrintPDF:162
Parsed 2 files for printing
[ERROR] 2023-10-20T12:27:04,718 @ qz.utils.PrintingUtilities:212
Failed to print
java.lang.NullPointerException: null
at qz.printer.PrintOutput.getPrintService(PrintOutput.java:61) ~[qz-tray.jar:?]
at qz.printer.action.PrintPDF.print(PrintPDF.java:183) ~[qz-tray.jar:?]
at qz.utils.PrintingUtilities.processPrintRequest(PrintingUtilities.java:202) ~[qz-tray.jar:?]
at qz.ws.PrintSocketClient.processMessage(PrintSocketClient.java:299) ~[qz-tray.jar:?]
at qz.ws.PrintSocketClient.onMessage(PrintSocketClient.java:165) ~[qz-tray.jar:?]
at jdk.internal.reflect.GeneratedMethodAccessor5.invoke(Unknown Source) ~[?:?]
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:?]
at java.lang.reflect.Method.invoke(Unknown Source) ~[?:?]
at org.eclipse.jetty.websocket.common.events.annotated.CallableMethod.call(CallableMethod.java:70) ~[qz-tray.jar:?]
at org.eclipse.jetty.websocket.common.events.annotated.OptionalSessionCallableMethod.call(OptionalSessionCallableMethod.java:68) ~[qz-tray.jar:?]
at org.eclipse.jetty.websocket.common.events.JettyAnnotatedEventDriver.lambda$onTextFrame$1(JettyAnnotatedEventDriver.java:270) ~[qz-tray.jar:?]
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:883) ~[qz-tray.jar:?]
at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1034) ~[qz-tray.jar:?]
at java.lang.Thread.run(Unknown Source) ~[?:?]
[TRACE] 2023-10-20T12:27:04,718 @ qz.utils.PrintingUtilities:179
Returning processor back to pool

Thanks for any help

tresf commented 8 months ago

Hi,

This is a duplicate of #1054. In short, print to host was never intended for Pixel API prints, just Raw API prints.

If your printer supports a PDF stream sent to it (many do) you could send it in Raw Base64 format, but you will lose any control over formatting (orientation, margins, size, duplex, etc).

We may eventually add driverless + printer discovery to the API, but if we do, this is a ways out, we'd need to implement some form of AirPrint or IPP Everywhere, or both, which is a considerable undertaking.

For now, I recommend mapping the printer locally if you need to use Pixel.

MatteoFeltrin commented 8 months ago

Ok thank you for the explanation, I had seen the issue you linked but it was not clear to me the reason, now it is!

tresf commented 8 months ago

Closed as duplicate of #1054