How do I prevent CUPS from auto-rotating my PDF?
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:
Trouble is, CUPS turns the job 270° degrees, so that it comes out sideways:
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.
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
40c40
< *DefaultPageSize: Custom.4x8in
---
> *DefaultPageSize: w288h576
80c80
< *PageSize w288h936/4.00x13.00": "<</PageSize[288 936]/ImagingBBox null>>setpagedevice"
---
> *PageSize w288h576/4.00x8.00": "<</PageSize[288 576]/ImagingBBox null>>setpagedevice"
98c98
< *DefaultPageRegion: Custom.4x8in
---
> *DefaultPageRegion: w288h576
138c138
< *PageRegion w288h936/4.00x13.00": "<</PageSize[288 936]/ImagingBBox null>>setpagedevice"
---
> *PageRegion w288h576/4.00x8.00": "<</PageSize[288 576]/ImagingBBox null>>setpagedevice"
154c154
< *DefaultImageableArea: Custom.4x8in
---
> *DefaultImageableArea: w288h576
194c194
< *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"
209c209
< *DefaultPaperDimension: Custom.4x8in
---
> *DefaultPaperDimension: w288h576
249c249
< *PaperDimension w288h936/4.00x13.00": "288.00 936.00"
---
> *PaperDimension w288h576/4.00x8.00": "288.00 576.00"