OpenPrinting / cups-filters

filters, backends, driverless utility, ... - Everything which CUPS 2.x needs to be used on non-Mac systems
Apache License 2.0
158 stars 126 forks source link

Issue with gstoraster with passing specific dimensions on Zebra with regular PPD #484

Closed waplet closed 2 years ago

waplet commented 2 years ago

Printfile: cf2.pdf

4x8 label on regular Zebra printer PPD STOCK.ppd.zip

cupsfilter -m application/vnd.cups-raster -d STOCK cf2.pdf -P /etc/cups/ppd/STOCK.ppd -o Media=Custom.4x8in > cf2.apple
DEBUG: argv[0]="STOCK"
DEBUG: argv[1]="1"
DEBUG: argv[2]="root"
DEBUG: argv[3]="cf2.pdf"
DEBUG: argv[4]="1"
DEBUG: argv[5]="Media=Custom.4x8in"
DEBUG: argv[6]="cf2.pdf"
DEBUG: envp[0]="<CFProcessPath>"
DEBUG: envp[1]="CONTENT_TYPE=application/pdf"
DEBUG: envp[2]="CUPS_DATADIR=/usr/share/cups"
DEBUG: envp[3]="CUPS_FONTPATH=/usr/share/cups/fonts"
DEBUG: envp[4]="CUPS_SERVERBIN=/usr/lib/cups"
DEBUG: envp[5]="CUPS_SERVERROOT=/etc/cups"
DEBUG: envp[6]="LANG=en_US.UTF8"
DEBUG: envp[7]="PATH=/usr/lib/cups/filter:/usr/bin:/usr/sbin:/bin:/usr/bin"
DEBUG: envp[8]="PPD=/etc/cups/ppd/STOCK.ppd"
DEBUG: envp[9]="PRINTER_INFO=STOCK"
DEBUG: envp[10]="PRINTER_LOCATION="
DEBUG: envp[11]="PRINTER=STOCK"
DEBUG: envp[12]="RIP_MAX_CACHE=128m"
DEBUG: envp[13]="USER=root"
DEBUG: envp[14]="CHARSET=utf-8"
DEBUG: envp[15]="FINAL_CONTENT_TYPE=application/vnd.cups-raster"
INFO: pdftopdf (PID 51995) started.
INFO: gstoraster (PID 51997) started.
DEBUG: OUTFORMAT="(null)", so output format will be CUPS/PWG Raster
DEBUG: pdftopdf: Last filter determined by the PPD: rastertolabel; FINAL_CONTENT_TYPE: application/vnd.cups-raster => pdftopdf will not log pages in page_log.
DEBUG: PDF interactive form and annotation flattening done via QPDF
INFO: pdftopdf (PID 51995) exited with no errors.
DEBUG: Color Manager: Calibration Mode/Off
INFO: Color Manager: no profiles specified in PPD
DEBUG: Color Manager: ICC Profile: None
DEBUG: Ghostscript using Any-Part-of-Pixel method to fill paths.
DEBUG: Ghostscript command line: gs -dQUIET -dSAFER -dNOPAUSE -dBATCH -dNOINTERPOLATE -dNOMEDIAATTRS -dShowAcroForm -sstdout=%stderr -sOutputFile=%stdout -sDEVICE=cups -r203x203 -dDEVICEWIDTHPOINTS=288 -dDEVICEHEIGHTPOINTS=576 -dcupsBitsPerColor=1 -dcupsColorOrder=0 -dcupsColorSpace=3 -dcupsCompression=-1 -scupsPageSizeName=Custom -I/usr/share/cups/fonts -c '<</.HWMargins[0.000000 0.000000 0.000000 0.000000] /Margins[0 0]>>setpagedevice' -f -_
DEBUG: envp[0]="FINAL_CONTENT_TYPE=application/vnd.cups-raster"
DEBUG: envp[1]="CHARSET=utf-8"
DEBUG: envp[2]="USER=root"
DEBUG: envp[3]="RIP_MAX_CACHE=128m"
DEBUG: envp[4]="PRINTER=STOCK"
DEBUG: envp[5]="PRINTER_LOCATION="
DEBUG: envp[6]="PRINTER_INFO=STOCK"
DEBUG: envp[7]="PPD=/etc/cups/ppd/STOCK.ppd"
DEBUG: envp[8]="PATH=/usr/lib/cups/filter:/usr/bin:/usr/sbin:/bin:/usr/bin"
DEBUG: envp[9]="LANG=en_US.UTF8"
DEBUG: envp[10]="CUPS_SERVERROOT=/etc/cups"
DEBUG: envp[11]="CUPS_SERVERBIN=/usr/lib/cups"
DEBUG: envp[12]="CUPS_FONTPATH=/usr/share/cups/fonts"
DEBUG: envp[13]="CUPS_DATADIR=/usr/share/cups"
DEBUG: envp[14]="CONTENT_TYPE=application/pdf"
INFO: Start rendering...
INFO: Processing page 1...
INFO: Processing page 2...
INFO: Rendering completed
INFO: gstoraster (PID 51997) exited with no errors.

Trying to print 4x8" label on similar Zebra but with a 4x8 paper loaded.

Ghostscript randomly decides to always rotate such dimensions in a landscape? Why?

cf2.apple.zip

And it's not possible to override, if i add additional landscape attribute, then it is just flipped by 180 degrees.

I have a feeling that this might not be related to cupsfilter, but the ghostscript cups driver itself?!

tillkamppeter commented 2 years ago

Your PPD file is badly broken:

$ cupstestppd STOCK.ppd 
../STOCK.ppd: FAIL
      **FAIL**  DefaultPageSize Custom.4x8in does not exist.
      **FAIL**  DefaultPageRegion Custom.4x8in does not exist.
      **FAIL**  REQUIRED ImageableArea for PageSize w288h576
                REF: Page 41, section 5.
                REF: Page 102, section 5.15.
      **FAIL**  REQUIRED PaperDimension for PageSize w288h576
                REF: Page 41, section 5.
                REF: Page 103, section 5.15.
      **FAIL**  Size "w288h576" has unexpected dimensions (0x0).
      **FAIL**  Size "w288h576" defined for PageSize but not for PageRegion.
[...]
$

As the errors are on the page size you are actually using it is very probable that Ghostscript got confused.

If you got the PPD file in this state from the printer manufacturer, please report a bug.

If you added page sizes by yourself, make sure that all lines for each added page size are correct and that cupstestppd does not report any FAIL.

If you use Custom.4x8in as page size you do not need to edit the manufacturers PPD file at all. It is in the nature of custom page sizes that they do not need to be explicitly listed in the PPD file.

waplet commented 2 years ago

Oh, yeah, seems that i was testing, if adding custom page sizes gives any better luck. But it turned out that it did not matter, the ghostscript always did landscape rotation.

Basically this is the one - https://opensource.apple.com/source/cups/cups-136/cups/ppd/zebra.ppd

tillkamppeter commented 2 years ago

I have found the bug now and fixed it, in Ghostscript's CUPS/PWG/Apple Raster output device. The fix will be included in the next Ghostscript release. I will also apply the patch to the Ghostscript package in Ubuntu, so it will be also included in the upcoming 22.10.

The problem was that the custom page size you have requested got matched against the PPD's page sizes and your PPD contains an 8x4in size and no 4x8in size. So your requested custom size got matched against the 8x4in size and so your page rotated. Now I have chabged the Ghostscript code to not try to match custom page sizes against the PPD's sizes.

waplet commented 2 years ago

Would this mean, that adding w288h576 correctly in PPD would have worked? Of course having a correct PPD.

tillkamppeter commented 2 years ago

Yes, it had worked if the entry had been complete and correct (consisting of a line for each PageSize, PageRegion, PaperDimension, and ImageableArea). With this (please check with cupstestppd) your requested size had been matched against the PPD successfully, already in the first attempt to use the given orientation and not in the 2nd run to try rotated by 90 degrees, and you had gotten the correct result. This way you can overcome the time until a fixed version of Ghostscript gets available to you.

With the Ghostscript fix the page size entries in the PPD do not matter any more as the custom size is not matched against them any more.

waplet commented 2 years ago

Okay, managed to update "base" driver in /usr/share/cups/drv/sample.drv , which generates the PPDs for added printers, just added 2 lines.

#media "w288h576/4.00x8.00\"" 288 576

and under ZPL Label driver

    MediaSize w288h576

And this seem to work with current GS version.

Really appreciate your knowledge and your help!