Skip to content
This repository was archived by the owner on Mar 10, 2026. It is now read-only.
This repository was archived by the owner on Mar 10, 2026. It is now read-only.

Landscape PDF prints incorrectly with orientation-requested=4 #2850

Closed

Description

@michaelrsweet

Version: 1.3.7
CUPS.org User: twaugh.redhat

I have an A4 landscape PDF creating using OpenOffice.org 2.3.0. When I try printing this to a Fedora 9 CUPS queue, the output is incorrect: it looks like the page has been rotated again, making it portrait but cropping the right-hand side of the original landscape page.

I printed it like this:

lp -oorientation-requested=4 landscape.pdf

Representation of original PDF:
+------+
|ABCDEF|
|ABCDEF|
+------+

Representation of printed page:
+---+
|ABC|
|ABC|
| |
+---+

(in fact the output looks stretched horizontally as well)

Printing the same document without 'orientation-requested=4' gives the correct (expected) output.

Activity

  1. michaelrsweet commented on Jun 6, 2008

    @michaelrsweet
    ContributorAuthor

    CUPS.org User: mike

    Which pdftops filter are you using in FC9?

  2. michaelrsweet commented on Jun 6, 2008

    @michaelrsweet
    ContributorAuthor

    CUPS.org User: twaugh.redhat

    It's the one that comes with CUPS 1.3.7. We don't replace it. (Perhaps you're confusing it with texttopaps, which we use to replace texttops..)

  3. michaelrsweet commented on Jul 14, 2008

    @michaelrsweet
    ContributorAuthor

    CUPS.org User: mike

    Fixed in Subversion repository.

    The fix is basically to not use the imageable area from the PPD file, and to no longer use the cupsRotation comment in the PostScript output. This yields essentially the same output as the CUPS 1.4 pdftops wrapper...

  4. michaelrsweet commented on Jul 14, 2008

    @michaelrsweet
    ContributorAuthor

    "str2850.patch":

    Index: pdftops/PSOutputDev.cxx

    --- pdftops/PSOutputDev.cxx (revision 7725)
    +++ pdftops/PSOutputDev.cxx (working copy)
    @@ -1166,8 +1166,6 @@

    if (width > height && width > imgWidth) cups_rotate = 90;

    - writePSFmt("%%cupsRotation: %d\n", cups_rotate);

    writePSFmt("%%Producer: xpdf/pdftops %s\n", xpdfVersion);
    xref->getDocInfo(&info);
    if (info.isDict() && info.dictLookup("Creator", &obj1)->isString()) {
    @@ -2519,8 +2517,9 @@
    } else {
    rotate = (360 - state->getRotate()) % 360;

    •  fprintf(stderr, "DEBUG: Page rotate=%d, width=%d, height=%d, imgWidth=%d, imgHeight=%d\n",
      
    •          state->getRotate(), width, height, imgWidth, imgHeight);
      
    •  fprintf(stderr, "DEBUG: getRotate=%d, rotate=%d, width=%d, height=%d, "
      
    •                  "imgWidth=%d, imgHeight=%d\n",
      
    •          state->getRotate(), rotate, width, height, imgWidth, imgHeight);
      

      if (rotate == 0 || rotate == 180) {
      if (width > height && width > imgWidth) {
      @@ -2539,6 +2538,9 @@
      }
      }

    • fprintf(stderr, "DEBUG: Using rotate=%d, width=%d, height=%d, imgWidth=%d, imgHeight=%d\n",

    •   rotate, width, height, imgWidth, imgHeight);
      

      writePSFmt("%%%%PageOrientation: %s\n",
      landscape ? "Landscape" : "Portrait");
      writePS("pdfStartPage\n");
      Index: pdftops/pdftops.cxx

      --- pdftops/pdftops.cxx (revision 7725)
      +++ pdftops/pdftops.cxx (working copy)
      @@ -4,7 +4,7 @@
      // PDF to PostScript filter front-end for the Common UNIX Printing
      // System (CUPS).
      //
      -// Copyright 2007 by Apple Inc.
      +// Copyright 2007-2008 by Apple Inc.
      // Copyright 1997-2006 by Easy Software Products.
      //
      // These coded instructions, statements, and computer programs are the
      @@ -70,8 +70,6 @@
      char buffer[8192]; // Copy buffer
      int bytes; // Bytes copied
      int width, length; // Size in points

    • int left, bottom, right, top;

    •               // Imageable area in points
      

      int orientation; // Orientation
      int temp; // Temporary var
      int duplex; // Duplex the output?
      @@ -110,10 +108,6 @@
      }

      // Default to "Universal" size - min of A4 and Letter...

    • left = 0;

    • bottom = 0;

    • right = 595;

    • top = 792;
      width = 595;
      length = 792;
      level = psLevel2;
      @@ -132,10 +126,6 @@

      if ((size = ppdPageSize(ppd, NULL)) != NULL)
      {

    •  left   = (int)size->left;
      
    •  bottom = (int)size->bottom;
      
    •  right  = (int)size->right;
      
    •  top    = (int)size->top;
      

      width = (int)size->width;
      length = (int)size->length;
      }
      @@ -172,49 +162,11 @@
      switch (orientation & 3)
      {
      case 0 : /* Portait */

    - break;

    • case 1 : /* Landscape */
    • temp = left;
    • left = bottom;

    - bottom = temp;

    • temp = right;
    • right = top;

    - top = temp;

    • temp = width;
    • width = length;
    • length = temp;

    - break;

     case 2 : /* Reverse Portrait */
    
    • temp = width - left;
    • left = width - right;

    - right = temp;

    • temp = length - bottom;
    • bottom = length - top;
    • top = temp;
      break;
    • case 1 : /* Landscape /
      case 3 : /
      Reverse Landscape */
    • temp = width - left;
    • left = width - right;

    - right = temp;

    • temp = length - bottom;
    • bottom = length - top;

    - top = temp;

    • temp = left;
    • left = bottom;

    - bottom = temp;

    • temp = right;
    • right = top;

    - top = temp;

    temp   = width;
    width  = length;
    length = temp;
    

    @@ -277,9 +229,13 @@
    // Only set paper size and area if we are fitting to the job's
    // page size or the pdftops.conf file does not contain
    // "psPaperSize match"...
    +

    • fprintf(stderr, "DEBUG: Setting paper dimensions to %dx%d!\n", width,
    •        length);
      
      globalParams->setPSPaperWidth(width);
      globalParams->setPSPaperHeight(length);
    • globalParams->setPSImageableArea(left, bottom, right, top);
    • globalParams->setPSImageableArea(0, 0, width, length);
      }

    globalParams->setPSDuplex(duplex);

  5. added this to the Stable milestone on Mar 17, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions