[cups.development] document rotation; WAS Re: Access to IPP attributes in filters and backends

Jon Peatfield J.S.Peatfield at damtp.cam.ac.uk
Fri Dec 14 13:42:15 PST 2007


On Fri, 14 Dec 2007, Michael R Sweet wrote:

>>  Should a filter not be allowed to alter the options seen by later filters
>>  to say that they have been acted on already and don't need to still be
>>  done?
>
> That's not possible; all of the filters are run in parallel, with the
> output from the first filter getting piped into the second, and so
> forth.

Fair enough.  I should have realised that (doh!)

>>  Otherwise when (say) a PDF job requests page rotation how does the pdftops
>>  tell pstops not to also attempt to rotate the job?
>
> The standard pdftops included with CUPS embeds a cupsRotation comment
> that tells pstops what orientation/rotation has been performed.
>
> If you use a different pdftops filter, that information is lost and
> you can get double-rotation.

In case my previous builds of pdftops were damaged I just rebuilt pdftops 
from the clean (unpatched at all) cups-1.3.4 sources.

Feeding it a pdf file which is landscape (US-Letter as it happens while 
our printers all have A4 set as their default papersize), I get 
'%cupsRotation: 0' in the postscript output irrespective of what I set 
orientation-requested to (or not set).

Adding a couple of trivial extra debug lines to the code (patch attached), 
I get the following messages while it runs:

$ ./pdftops 1 jp107 mathworks 1 '' ~/mathworks-2007.pdf > /tmp/mathworks-2007.pdftops-1.ps
DEBUG: JSP added before orientation-check left=0 bottom=0 right=595 top=792 width=595 length=792
DEBUG: JSP added after orientation-check left=0 bottom=0 right=595 top=792 width=595 length=792 orientation=0
DEBUG: pdftops - level = 2, width = 595, length = 792
DEBUG: JSP added cupsRotate=0, pageRotate=0 width=792, height=612, imgWidth=792
DEBUG: Page rotate=0, width=792, height=612, imgWidth=595, imgHeight=792
DEBUG: Page rotate=0, width=792, height=612, imgWidth=595, imgHeight=792
DEBUG: Page rotate=0, width=792, height=612, imgWidth=595, imgHeight=792
DEBUG: Page rotate=0, width=792, height=612, imgWidth=595, imgHeight=792

$ ./pdftops 1 jp107 mathworks 1 'orientation-requested=4' ~/mathworks-2007.pdf > /tmp/mathworks-2007.pdftops-2.ps
DEBUG: JSP added before orientation-check left=0 bottom=0 right=595 top=792 width=595 length=792
DEBUG: JSP added after orientation-check left=0 bottom=0 right=792 top=595 width=792 length=595 orientation=1
DEBUG: pdftops - level = 2, width = 792, length = 595
DEBUG: JSP added cupsRotate=0, pageRotate=0 width=792, height=612, imgWidth=792
DEBUG: Page rotate=0, width=792, height=612, imgWidth=792, imgHeight=595
DEBUG: Page rotate=0, width=792, height=612, imgWidth=792, imgHeight=595
DEBUG: Page rotate=0, width=792, height=612, imgWidth=792, imgHeight=595
DEBUG: Page rotate=0, width=792, height=612, imgWidth=792, imgHeight=595

$ grep cupsRotation /tmp/mathworks-2007.pdftops-{1,2}.ps
/tmp/mathworks-2007.pdftops-1.ps:%cupsRotation: 0
/tmp/mathworks-2007.pdftops-2.ps:%cupsRotation: 0
$ egrep 'BoundingBox|DocumentMedia' /tmp/mathworks-2007.pdftops-{1,2}.ps
/tmp/mathworks-2007.pdftops-1.ps:%%DocumentMedia: plain 595 792 0 () ()
/tmp/mathworks-2007.pdftops-1.ps:%%BoundingBox: 0 0 595 792
/tmp/mathworks-2007.pdftops-2.ps:%%DocumentMedia: plain 792 595 0 () ()
/tmp/mathworks-2007.pdftops-2.ps:%%BoundingBox: 0 0 792 595

Looking at the resulting ps files in gs they don't seem to have the same 
orientation.  In any case then running the files through pstops won't know 
that a rotate has been done so in the 'orientation-requested=4' case it 
then does another rotate.

I'm clearly missing something about what is supposed to be happening but 
pdftops also looks (to me) like it has code to do some kind of auto-rotate 
in PSOutputDev::startPage() or maybe I'm just getting utterly lost in the 
pdftops code.

What happens for other people?  Is it something weird here?

  -- Jon
-------------- next part --------------
--- PSOutputDev.cxx.orig	2007-05-08 17:28:32.000000000 +0100
+++ PSOutputDev.cxx	2007-12-14 20:30:29.000000000 +0000
@@ -1167,6 +1167,8 @@
   if (width > height && width > imgWidth) cups_rotate = 90;
 
   writePSFmt("%%cupsRotation: %d\n", cups_rotate);
+  fprintf(stderr, "DEBUG: JSP added cupsRotate=%d, pageRotate=%d width=%d, height=%d, imgWidth=%d\n",
+              cups_rotate, pageRotate, width, height, imgWidth);
 
   writePSFmt("%%Producer: xpdf/pdftops %s\n", xpdfVersion);
   xref->getDocInfo(&info);
--- pdftops.cxx.orig	2007-07-11 22:46:42.000000000 +0100
+++ pdftops.cxx	2007-12-14 20:28:32.000000000 +0000
@@ -143,6 +143,9 @@
     level = ppd->language_level == 1 ? psLevel1 : psLevel2;
   }
 
+  fprintf(stderr, "DEBUG: JSP added before orientation-check left=%d bottom=%d right=%d top=%d width=%d length=%d\n",
+	  left, bottom, right, top, width, length);
+
   // Track the orientation of the print job and update the page
   // dimensions and margins as needed...
   orientation = 0;
@@ -221,6 +224,9 @@
 	break;
   }
 
+  fprintf(stderr, "DEBUG: JSP added after orientation-check left=%d bottom=%d right=%d top=%d width=%d length=%d orientation=%d\n",
+	  left, bottom, right, top, width, length, orientation);
+
   if ((val = cupsGetOption("debug", num_options, options)) != NULL &&
       strcasecmp(val, "no") && strcasecmp(val, "off") &&
       strcasecmp(val, "false"))


More information about the cups mailing list