qzind / tray

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

Page is Printing but getting printer status as WARN - DELETED #1250

Closed fearless0307 closed 2 months ago

fearless0307 commented 2 months ago

Hi Team,

I am facing a issue in Windows OS while printing in a Label printer (TSC DA310 using Seagull driver). When I send a command for printing, the status callback are:

SPOOLING: Level: INFO, From: TSC DA310, EventType: JOB, Code: 8, JobId: 11, Job Name: QZ Tray Raw Print
PRINTING: Level: INFO, From: TSC DA310, EventType: JOB, Code: 16, JobId: 11, Job Name: QZ Tray Raw Print
RETAINED: Level: INFO, From: TSC DA310, EventType: JOB, Code: 8192, JobId: 11, Job Name: QZ Tray Raw Print
COMPLETE: Level: INFO, From: TSC DA310, EventType: JOB, Code: 128, JobId: 11, Job Name: QZ Tray Raw Print
DELETING: Level: WARN, From: TSC DA310, EventType: JOB, Code: 4, JobId: 11, Job Name: QZ Tray Raw Print
DELETED: Level: WARN, From: TSC DA310, EventType: JOB, Code: 256, JobId: 11, Job Name: QZ Tray Raw Print

I tried setting the printer option as guided in issue-888

Code to trigger print:

let config = qz.configs.create("printer name", {forceRaw: true});
let data = [];  // ZPL data
qz.print(config, data);

QzTray version: 2.2.3 Windows OS version: tried in both 10 and 11

Please help here.

Thanks

tresf commented 2 months ago

Hi,

Why do you think that this is a bug? By default in Windows, documents are deleted, unless you ask the printer driver to keep spooled documents. This should not affect the reliability of your printing, but rather affects the retention on your PC.

tresf commented 2 months ago

I tried the same code in MacOS, but there is didn't give such warnings. I am trying to build an auto print system, where a user can scan a barcode using a barcode scanner which populates in the in UI, it will hit a API

If the APIs behave differently when a document is deleted, I would agree that that's a bug. CUPS is weird because it preserves the job on disk for a while incase you want to reprint it.

sudo cupsctl webinterface=yes

PDFwriter (as example): http://localhost:631/printers/PDFwriter?which_jobs=completed

image

This is unintuitive because the MacOS printing dialog does not show the job being retained. I'm not sure why however if you can reproduce that deleting a JOB doesn't trigger the same type of API warning, we'd be happy to investigate.

tresf commented 2 months ago

For your use-case I would ignore any status events for JOB that are DELETING or DELETED. Note, printers can be deleted too, those events may want to remain. :)

https://github.com/qzind/tray/blob/6e1a503bc9b535c96d3ad0edde8e33c00bc08790/src/qz/printer/status/job/NativeJobStatus.java#L13-L14

fearless0307 commented 2 months ago

Hi,

I am building an app where an API will return a PDF link and using QzTray It will auto-print in the selected printer. To make sure that the printer is connected and ready to print, I am using printer event callback and whenever the severity != "INFO", I mark the printer as some error.

For now, we have changed the above check to not treat severity == "WARN" and statusText == "DELETED" as an error and keep the printer status as ready to print.

I just wanted to know why the same code behaves differently in MacOS and Windows, is it a code issue or it's by design, or something else (as you said in the above comment, it might be due to CUPS)?

Screenshot 2024-04-15 at 11 15 23 PM

Thanks for the confirmation.

tresf commented 2 months ago

I would assume this is a CUPS-ism. WARN might not be the best severity in hindsight, but it's what we selected when we wrote the API. We might switch this back to INFO, as it seems more suitable.

tresf commented 2 months ago

Starting with QZ Tray 2.2.4, this will be INFO, instead of WARN. Thanks for the report. If you need a build in advance of this release, please reach out to support@qz.io (commercial license) or you may build your own following our compilation guide.