[cups.general] Auto-detecting PDF orientation for auto-rotation

Johannes Meixner jsmeix at suse.de
Wed Mar 20 02:18:27 PDT 2013


Hello,

On Mar 20 13:21 Kai Hendry wrote (excerpt):
> I am looking for a solution whereby PDFs are auto-rotated.

Shouldn't the CUPS printing option "-o fit-to-page" do it?

See "Scaling to Fit" for CUPS 1.5 at
http://www.cups.org/documentation.php/doc-1.5/options.html
and for CUPS 1.6 at
http://www.cups.org/documentation.php/doc-1.6/options.html

For testing you may do the following:

Create two PDFs in portrait and landscape orientation:
-------------------------------------------------------------------
$ echo "portrait" \
   | a2ps -1 -M a4 -o- \
   | ps2pdf -sPAPERSIZE=a4 - /tmp/portrait.a4.pdf

$ echo "landscape" \
   | a2ps -1 -r -M a4 -o- \
   | ps2pdf -sPAPERSIZE=a4 - /tmp/landscape.a4.pdf
-------------------------------------------------------------------
(ps2pdf is /usr/bin/ps2pdf from Ghostscript)

Verify that the PDFs are actually portrait versus landscape:
-------------------------------------------------------------------
$ gs -sDEVICE=bbox -dBATCH -dNOPAUSE /tmp/portrait.a4.pdf 2>&1 \
   | grep '%BoundingBox'
%%BoundingBox: 23 23 572 815

$ gs -sDEVICE=bbox -dBATCH -dNOPAUSE /tmp/landscape.a4.pdf 2>&1 \
   | grep '%BoundingBox'
%%BoundingBox: 23 23 819 568
-------------------------------------------------------------------

Print them with and without "-o fit-to-page":
-------------------------------------------------------------------
$ lp -d <queue_name> /tmp/portrait.a4.pdf

$ lp -d <queue_name> /tmp/landscape.a4.pdf

$ lp -d <queue_name> -o fit-to-page /tmp/portrait.a4.pdf

$ lp -d <queue_name> -o fit-to-page /tmp/landscape.a4.pdf
-------------------------------------------------------------------

When you print to a real PostScript printer it may depend
on the printer's internal settings whether or not the
printer itself may autorotate pages to fit them on the paper.

Also the filters/drivers in the printing system that convert PDF
to PostScript and/or to other printer-specific data (e.g. PCL)
may autorotate pages, see Till Kamppeter's initial description in
https://bugs.linuxfoundation.org/show_bug.cgi?id=1080
----------------------------------------------------------------------------
Note that in a full printing workflow the bug often gets overlooked
as some printer drivers (Like the CUPS Raster output device of Ghostscript)
or built-in PostScript and PDF interpreters of printers rotate the PDFs
by themselves.
Other drivers, like the "ljet4" driver of Ghostscript do not rotate
the page content to fit onto the page.
----------------------------------------------------------------------------


Kind Regards
Johannes Meixner
-- 
SUSE LINUX Products GmbH -- Maxfeldstrasse 5 -- 90409 Nuernberg -- Germany
HRB 16746 (AG Nuernberg) GF: Jeff Hawn, Jennifer Guild, Felix Imendoerffer





More information about the cups mailing list