On my Ubuntu 16.04 LTS system, I have a Citizen CL-S621Z label printer, with 50x80mm labels (portrait), and a 50x80mm PDF that I wish to print:

enter image description here

Trouble is, CUPS turns the job 270° degrees, so that it comes out sideways:

enter image description here

The input PDF file has no page rotation itself, as revealed by pdfinfo:

admin@bukittinggi ~> pdfinfo label.pdf
Creator:        cairo 1.13.1 (http://cairographics.org)
Producer:       cairo 1.13.1 (http://cairographics.org)
Tagged:         no
UserProperties: no
Suspects:       no
Form:           none
JavaScript:     no
Pages:          1
Encrypted:      no
Page size:      141.732 x 226.772 pts
Page rot:       0
File size:      32443 bytes
Optimized:      no
PDF version:    1.5

My print command line is:

lpr label.pdf

I've attempted a number of options to prevent automatic page rotation, including -o 'nopdfAutoRotate', -o portrait, -o landscape and -o orientation-requested=N (for values of N between 0 and 7), and none of these seem to have any effect.

The job seems to pass through pdftopdf and then pdftops in the CUPS filter graph, and as far as I can tell, the rotation occurs when the job hits the latter filter, after which the page rotation is set to 270°:

~> /usr/sbin/cupsfilter -P test.ppd -m application/vnd.cups-postscript label.pdf  > filtered.ps
~> ps2pdf filtered.ps
~> pdfinfo filtered.pdf
Page size:      142 x 227 pts
Page rot:       270

/usr/lib/cups/filter/pdftops is from cups-filters-core-drivers version 1.8.3-2ubuntu3. Oddly, the problem does not occur on Raspbian, which has cups-filters-core-drivers version 1.0.61-5+deb8u3.

Update: I was able to get the desired orientation by carefully editing the PPD file to exactly match the label dimensions:

*DefaultPageSize: w142h227
*PageSize w142h227/1.97x3.15": "<</PageSize[142 227]/ImagingBBox null>>setpagedevice"
*PageRegion w142h227/1.97x3.15": "<</PageSize[142 227]/ImagingBBox null>>setpagedevice"
*ImageableArea w142h227/1.97x3.15": "0 0 142 227"
*PaperDimension w142h227/1.97x3.15": "142 227"

Thanks to Michael from the CUPS team.

  • make it rotate another -90? >:-) – Rinzwind Jul 9 '16 at 15:56
  • Thanks for the suggestion. Do you know how I can hook into the CUPS filter chain and trigger the rotation? – crishoj Jul 9 '16 at 16:23
  • 1
    I've gone through exactly same procedure like you. Lost two days trying all that "working" options in CUPS documentation - nothing worked. Luckily solution from @timicu below worked like charm. – spaceman117X Jan 26 '18 at 10:08

We had the same problem with a Zebra Z4MPLUS printer using the PPD file from Zebra. The PPD file had 8.00x4.00" as a label size but that did not work for us. Using Custom 4x8in also did not work. We had to create a 4.00x8.00" label size in the PPD file and then select it in Cups. We did this by editing a 4.00x13.00" label size in the PPD which we knew we wouldn't need. Here is a diff original.ppd edited.ppd

< *DefaultPageSize: Custom.4x8in
> *DefaultPageSize: w288h576
< *PageSize w288h936/4.00x13.00": "<</PageSize[288 936]/ImagingBBox null>>setpagedevice"
> *PageSize w288h576/4.00x8.00": "<</PageSize[288 576]/ImagingBBox null>>setpagedevice"
< *DefaultPageRegion: Custom.4x8in
> *DefaultPageRegion: w288h576
< *PageRegion w288h936/4.00x13.00": "<</PageSize[288 936]/ImagingBBox null>>setpagedevice"
> *PageRegion w288h576/4.00x8.00": "<</PageSize[288 576]/ImagingBBox null>>setpagedevice"
< *DefaultImageableArea: Custom.4x8in
> *DefaultImageableArea: w288h576
< *ImageableArea w288h936/4.00x13.00": "0.00 0.00 288.00 936.00"
> *ImageableArea w288h576/4.00x8.00": "0.00 0.00 288.00 576.00"
< *DefaultPaperDimension: Custom.4x8in
> *DefaultPaperDimension: w288h576
< *PaperDimension w288h936/4.00x13.00": "288.00 936.00"
> *PaperDimension w288h576/4.00x8.00": "288.00 576.00"
  • 1
    Man, this solution works copy/paste for Zebra ZT230 as well. Thank you so much! – spaceman117X Jan 26 '18 at 10:00
  • 1
    You have saved my ass! I'd have never figured this out on my own. I can finally print DHL labels with the Zebra GC420t on Linux. Thanks so much! – László Monda Mar 13 '18 at 20:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.