Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
waplet opened this issue Sep 23, 2022 · 6 comments

Comments

@waplet
Copy link

waplet commented Sep 23, 2022

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
Copy link
Member

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
Copy link
Author

waplet commented Sep 24, 2022

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
Copy link
Member

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.

chris-liddell pushed a commit to ArtifexSoftware/ghostpdl that referenced this issue Sep 25, 2022
… PPD

If for a job a custom page size is selected, indicated by something
like "-scupsPageSizeName=Custom.4x8in" or "-scupsPageSizeName=Custom",
do not try to match the requested page size, given by standard
Ghostscript parameters like
"-dDEVICEWIDTHPOINTS=... -dDEVICEHEIGHTPOINTS=...", with the supported
page sizes defined in the PPD file.

This avoids unwished rotations as reported in

    OpenPrinting/cups-filters#484

and also unwished size mismatches if the custom size is very close to
a size defined in the PPD file.
@waplet
Copy link
Author

waplet commented Sep 26, 2022

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

@tillkamppeter
Copy link
Member

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
Copy link
Author

waplet commented Sep 26, 2022

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!

tillkamppeter added a commit that referenced this issue Oct 17, 2022
libcupsfilters 2.x (cfFilterGhostscript() filter function) requires
Ghostscript 10.00.0 for a "cups"/"pwgraster"/"appleraster"/"urf"
output device with full support for PPD-less use. Ghostscript 10.01.0
is recommended, to fix

#484

Updated comments in cupsfilters/ghostscript.c and README
appropriately.
tillkamppeter added a commit to OpenPrinting/hplip-printer-app that referenced this issue Oct 17, 2022
Also added patch from upstream (to be included in 10.01.0) to not
match custom page sizes against the sizes defined in the PPD file when
the CUPS/PWG/Apple Raster output device is used (Upstream commit
387f09416, cups-filters issue
OpenPrinting/cups-filters#484).
tillkamppeter added a commit to OpenPrinting/ghostscript-printer-app that referenced this issue Oct 17, 2022
Also added patch from upstream (to be included in 10.01.0) to not
match custom page sizes against the sizes defined in the PPD file when
the CUPS/PWG/Apple Raster output device is used (Upstream commit
387f09416, cups-filters issue
OpenPrinting/cups-filters#484).
tillkamppeter added a commit to OpenPrinting/gutenprint-printer-app that referenced this issue Oct 17, 2022
Also added patch from upstream (to be included in 10.01.0) to not
match custom page sizes against the sizes defined in the PPD file when
the CUPS/PWG/Apple Raster output device is used (Upstream commit
387f09416, cups-filters issue
OpenPrinting/cups-filters#484).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants