qzind / tray

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

Using "Scale Content" in 2.0.1 breaks density logic #92

Closed lite1979 closed 8 years ago

lite1979 commented 8 years ago

Using either Ubuntu 14.04 or Linux Mint 17.3

In comparison with 2.0.0, pixel printing is mostly broken for thermal receipt (continuous paper) printers when using 'scale content'. Not using 'scale content' results in undesirable images being printed.

Using a zebra label printer, however, results are identical to the previous code.

Stack trace showed "no usable DPI" for my star printer, which makes me think it's related to either the conversion, or how it reads the default dpi of the printer. I'll add a stack trace from my other machine in a few minutes.

Forcing a DPI of 72 gave me a more usable image, both with and without enabling scale content.

debug.txt

tresf commented 8 years ago

The logs suggest the DPI couldn't be retrieved from the Epson and the Star printer. The output of lpoptions -p [PRINTER_NAME] -l should explain a bit more why the DPIs can't be detected.

For most printers, something like this is returned: Resolution/Output Resolution: 150dpi *300dpi 600dpi 1200dpi 2400dpi, with *300dpi being the default resolution. This is working for the Zebra driver as it selects *203 but we haven't tested this on Epson or Star yet.

Another way to circumvent the PDF scaling issues is to use the rasterize: false flag (or the checkbox in sample.html) as it should allow PDFBOX to do the scaling for you although this feature won't be available for HTML until 2.1.

AFAIK, the only major change to this logic was adding the fallbackDensity support via https://github.com/qzind/tray/commit/fe38f7ca02799f8ccdc1431378e7ee4534f4a40f and I don't see anything in it that should have made this impact. Is there a chance this wasn't tested with these same settings in 2.0.0?

Also curious if @bberenz has any thoughts.

Currently, we fallback to 600dpi if non was detected.

lite1979 commented 8 years ago

Looks like that works well for the Zebra, for for the Epson and the Star, either the format (180x180dpi for the Epson), or the lack of any defined resolutions at all in the case of the Star printer is messing with the DPI logic.

'PDFLabelZ' is the queue for 2d/pixel-based jobs sent to my Zebra LP2844-Z:

lite@lite-desktop:~$ lpoptions -p PDFLabelZ -l
PageSize/Media Size: w90h18 w90h162 w108h18 w108h36 w108h72 w108h144 w144h26 w144h36 w144h72 w144h90 w144h288 w144h396 w162h36 w162h90 w162h288 w162h396 w171h396 w180h72 w180h144 w198h90 w216h72 w216h90 w216h144 w216h216 w216h360 w234h144 w234h360 w234h396 w234h419 w234h563 w252h72 w288h72 w288h144 w288h180 w288h216 w288h288 w288h360 *w288h432 w288h468 w288h936 w432h72 w432h144 w432h216 w432h288 w432h360 w432h432 w432h468 w576h72 w576h144 w576h216 w576h288 w576h360 w576h432 w576h468 Custom.WIDTHxHEIGHT
Resolution/Resolution: *203dpi 300dpi 600dpi
zeMediaTracking/Media Tracking: Continuous *Web Mark
MediaType/Media Type: *Saved Thermal Direct
Darkness/Darkness: *-1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
zePrintRate/Print Rate: *Default 1 2 3 4 5 6 7 8 9 10 11 12
zeLabelTop/Label Top: *200 -120 -115 -110 -105 -100 -95 -90 -85 -80 -75 -70 -65 -60 -55 -50 -45 -40 -35 -30 -25 -20 -15 -10 -5 0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 105 110 115 120
zePrintMode/Print Mode: *Saved Tear Peel Rewind Applicator Cutter
zeTearOffPosition/Tear-Off Adjust Position: *1000 -120 -115 -110 -105 -100 -95 -90 -85 -80 -75 -70 -65 -60 -55 -50 -45 -40 -35 -30 -25 -20 -15 -10 -5 0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 105 110 115 120
zeErrorReprint/Reprint After Error: *Saved Always Never

'Epson-TM-BA-Thermal' is the queue for 2d/pixel-based jobs sent to my Epson TM-T88V:

lite@lite-desktop:~$ lpoptions -p Epson-TM-BA-Thermal -l
PageSize/Media Size: RP82.5x297 *RP80x297 RP60x297 RP58x297 RP82.5x2000 RP80x2000 RP60x2000 RP58x2000 A4 LT Custom.WIDTHxHEIGHT
TmxPrintingSpeed/Printing Speed: *Auto 1 2 3 4
TmxPaperReduction/Paper Reduction: Off Top *Bottom Both
TmxPaperSource/Paper Source: DocFeedCut *DocFeedNoCut DocNoFeedCut DocNoFeedNoCut PageFeedCut PageFeedNoCut PageNoFeedCut
TmxPrinterType/Printer Type: *ThermalReceipt
Resolution/Resolution: *180x180dpi 203x203dpi 162x162dpi 144x144dpi 126x126dpi 108x108dpi 90x90dpi 72x72dpi 68x68dpi 48x48dpi 0182x182dpi 0162x162dpi 0142x142dpi 0121x121dpi 0102x102dpi 081x81dpi 077x77dpi 056x56dpi
TmxFeedPitch/Pitch of Feed: 180.0 203.2 *360.0 406.4
TmxMaxBandWidth/Maximum Band Width: 360 384 416 420 436 *512 576 640
TmxBandLines/Band Lines: *256
TmxSpeedControl/Speed Control: 0,0,0,0 -1,-1,-1,-1 9,7,4,1 10,7,4,1 11,8,4,1 *13,9,5,1
TmxBuzzerControl/Buzzer: Off Before *After
TmxSoundPattern/Sound Pattern: *Internal A B C D E
TmxBuzzerRepeat/Buzzer Repeat: *1 2 3 5
TmxDrawerControl/Cash Drawer: *None Drawer#1,Before Drawer#1,After Drawer#2,Before Drawer#2,After
TmxPulseOnTime/Pulse On Time: *20,10,100 40,20,100 60,30,120 80,40,160 100,50,200 120,60,240

'TSP650-Cutter' is the queue for 2d/pixel-based jobs sent to my Star TSP650II

lpoptions -p TSP650-Cutter -l
PageSize/Media Size: X50D8MMY30MM X50D8MMY40MM X50D8MMY50MM X50D8MMY60MM X50D8MMY70MM X50D8MMY80MM X50D8MMY90MM X50D8MMY100MM X50D8MMY110MM X50D8MMY120MM X50D8MMY130MM X50D8MMY140MM X50D8MMY150MM X50D8MMY160MM X50D8MMY170MM X50D8MMY180MM X50D8MMY190MM X50D8MMY200MM X50D8MMY1500MM X50D8MMY2000MM X72MMY30MM X72MMY40MM X72MMY50MM X72MMY60MM X72MMY70MM X72MMY80MM X72MMY90MM X72MMY100MM X72MMY110MM X72MMY120MM X72MMY130MM X72MMY140MM X72MMY150MM X72MMY160MM X72MMY170MM X72MMY180MM X72MMY190MM X72MMY200MM X72MMY1000MM X72MMY1500MM X72MMY2000MM A4 *Letter Legal Custom.WIDTHxHEIGHT
PageCutType/1. Page Feed Type: *0NoCutPage 3TearBarPage
DocCutType/2. Document Feed Type: 0NoCutDoc *3TearBarDoc
PrintSpeed/1. Print Speed: *0High 1Middle 2Low
PrintDensity/2. Print Density: 0Minus3 1Minus2 2Minus1 *3ZERO 4Plus1 5Plus2 6Plus3
PageType/3. Page Type: *0Variable 1Fixed
CashDrawerSetting/1. Cash Drawer: *0DoNotOpenDrawers 1OpenDrawer1 2OpenDrawer2 3OpenDrawer3
CashDrawer1PulseWidth/2. Cash Drawer 1 Pulse Width: 0Millis10 1Millis100 *2Millis200 3Millis300 4Millis400 5Millis500 6Millis600 7Millis700 8Millis800 9Millis900 10Millis1000 11Millis1100 12Millis1200
Buzzer1Setting/1. Buzzer 1: *0NoUse 1DocumentTop 2DocumentBtm
Buzzer1OnTime/2. Buzzer 1 - On Time: *0Millis20 1Millis40 2Millis100 3Millis200 4Millis500 5Millis1000 6Millis2000 7Millis5000
Buzzer1OffTime/3. Buzzer 1 - Off Time: *0Millis20 1Millis40 2Millis100 3Millis200 4Millis500 5Millis1000 6Millis2000 7Millis5000
Buzzer2Repeat/4. Buzzer 2 - Repeat: *0Repeat1 1Repeat2 2Repeat3 3Repeat5 4Repeat10 5Repeat15 6Repeat20
DataTreatmentRecoverFromError/1. DataTreatmentRecoverFromError: 0NoUse *1ClearDataByDocumentUnit
tresf commented 8 years ago

Ok. Your original log file shows invalid density for TSP650-Cutter, ,EPSON-XP-620-Series.

Rather than providing a log with several tests that may not apply to the bug, let's make one single log that does. In the mean time, I'll try to reproduce from a VM.

tresf commented 8 years ago

Install and configure driver:

  1. Downloaded and installed the TM/BA Series printer from here.
  2. Manually added printer as network HP/JetDirect and chose Epson TM BA driver when prompted.
  3. Rebooted (only way to get printer to list in Java)
  4. Loaded up QZ Tray

Testing:

  1. Printed using default settings:
    • Rasterize: true
    • Scale Content: true
    • ⛔ FAIL - Doesn't print
  2. Printed using:
    • Rasterize: false
    • Scale Content: true
    • ⛔ FAIL - Doesn't print
  3. Printed using:
    • Rasterize: false
    • Scale Content: false
    • ✅ PASS - Results identical to launching PDFBOX from command line (java -jar pdfbox-app-[version].jar PrintPDF ~/tray/resources/pdf_sample.pdf)
tresf commented 8 years ago

I was wrong about the crash logs, they were left over from a separate crash.

I did a bunch of tests but no matter what I kept getting a message Stopped. Filter failed. and it was not consistent but required me to go to the CUPS jobs listing and cancel the print jobs one-by-one. Once, a reboot of the printer was needed.

Sometimes the jobs would sit out there for 1 minute and eventually print, sometimes 3 minutes and never print.

After opening up the jobs page, I noticed QZ Tray 2.0.0's jobs were more than twice the size (4MB) as compared to QZ Tray 2.0.1 (2.8MB, 1.5MB).

This seems to be caused by the new PDF committed here: https://github.com/qzind/tray/commit/6190ad5adfd8f4a5e0a1089b8ba7f6f281181b0b

What still fails in both versions is rasterize: true, scaleContent: true. All other combinations passed once I swapped out the old PDF, which can be downloaded here:

https://github.com/qzind/tray/blob/8b43149bff6a19f04c945796deda0236a7d5b01e/assets/pdf_sample.pdf

tresf commented 8 years ago

I tracked this down to a GhostScript bug with GhostScript 9.10. Updating to GhostScript 9.15 fixes this issue.

Unfortunately, the latest version of GhostScript available for Ubuntu 14.04 is 9.10, so obtaining 9.15 requires manual installation.

The technique I used was:

sudo apt-add-repository ppa:anton+/photo-video-apps
sudo apt-get update
sudo apt-get install --reinstall ghostscript

I can confirm that the PDF prints with all of the various options with GhostScript 9.15.

Closing, marking as not our bug, since this has already been fixed upstream. Will open a separate issue for the HTML issues if applicable.