Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
For bugs related to Red Hat Enterprise Linux 5 product line. The current stable release is 5.10. For Red Hat Enterprise Linux 6 and above, please visit Red Hat JIRA https://issues.redhat.com/secure/CreateIssue!default.jspa?pid=12332745 to report new issues.

Bug 520141

Summary: page-label misplaced by pstops filter in landscape
Product: Red Hat Enterprise Linux 5 Reporter: Olivier Fourdan <ofourdan>
Component: cupsAssignee: Tim Waugh <twaugh>
Status: CLOSED WONTFIX QA Contact: qe-baseos-daemons
Severity: urgent Docs Contact:
Priority: urgent    
Version: 5.4CC: azelinka, bmason, ddumas, jpopelka, jwest, kem, pknirsch
Target Milestone: rcKeywords: Patch, Reopened
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 526891 (view as bug list) Environment:
Last Closed: 2012-07-31 11:01:59 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 526891    
Bug Blocks: 499522, 668957, 743405, 807971    
Attachments:
Description Flags
Proposed patch
none
ppd file
none
Another ppd file
none
landscape.pdf
none
New proposed patch none

Description Olivier Fourdan 2009-08-28 15:42:58 UTC
Created attachment 359088 [details]
Proposed patch

Description of problem:

pstops will not place the page labels at the proper position when printing in landscape.

Version-Release number of selected component (if applicable):

cups-libs-1.3.7-11

How reproducible:

100% reproducible

Steps to Reproduce:
1. Create a Postscript printer queue
2. Print a text document with a page-label in landscape
   lpr -o "page-label=Hello landscape" /etc/passwd
  
Actual results:

The page label is not seen on the page

Expected results:

The page label is shown on the page in landscape mode

Additional info:

The page-label gets printed differently depending on the orientation of the document, but only for multiple sheet per page, and only for some values:

In do_setup() from filter/pstops.c the page-label is rotated only for 2 and 6 pages on each sheet:

  2015
  2016   if (doc->number_up == 2 || doc->number_up == 6)
  2017   {
  2018    /*
  2019     * For 2- and 6-up output, rotate the labels to match the orientation
  2020     * of the pages...
  2021     */
  2022
  2023     if (Orientation & 1)
  2024       write_label_prolog(doc, doc->page_label, PageBottom,
  2025                          PageWidth - PageLength + PageTop, PageLength);
  2026     else
  2027       write_label_prolog(doc, doc->page_label, PageLeft, PageRight,
  2028                          PageLength);
  2029   }
  2030   else
  2031     write_label_prolog(doc, doc->page_label, PageBottom, PageTop, PageWidth);
  2032 }
  2033 

When using landscape, the orientation is set initially to "1" (0 for portrait) in SetCommonOptions() from filter/common.c but that value is later overridden in copy_comments() from filter/pstops.c:

  [...]
  725     else if (!strncmp(line, "%cupsRotation:", 14))
  726     {
  727      /*
  728       * Reset orientation of document?
  729       */
  730
  731       int orient = (atoi(line + 14) / 90) & 3;
  732
  733       if (orient != Orientation)
  734       {
  735        /*
  736         * Yes, update things so that the pages come out right...
  737         */
  738
  739         Orientation = (4 - Orientation + orient) & 3;
  740         UpdatePageVars();
  741         Orientation = orient;
  742       }
  743     }
  [...]

By using the initial value passed for orientation to position the label, it shows on the page.

The attached patch does two things:

1. Save the original orientation to use it when positioning the label
2. Use that orientation to palce the label accordingly

This patch would need more intensive testing and review :)

Comment 2 Tim Waugh 2009-09-02 14:32:17 UTC
I haven't been able to reproduce this.  Please attach the PPD used in your testing.

Comment 3 Olivier Fourdan 2009-09-02 14:55:01 UTC
Created attachment 359540 [details]
ppd file

The issue has been reported on a HP LaserJet 9000, and reproduced by our partner also on a HP Laserjet 4250dtn.

Attaching the ppd file for the 4250dtn

Comment 4 Olivier Fourdan 2009-09-02 14:57:25 UTC
Created attachment 359541 [details]
Another ppd file

This ppd file is also used according to the /etc/cups/printers.conf

Comment 6 Tim Waugh 2009-09-02 17:41:52 UTC
Created attachment 359561 [details]
landscape.pdf

OK, problem reproduced.  Here is the real test procedure:

1. Print a landscape PDF like so: lp -opage-label=label landscape.pdf

The output is incorrect and appears as follows:

+----------------+
|Landscape       |
|                |
|  _______       |
|  |label|       |
+----------------+

Correct output would contain two labels, one at each side of the page, in the middle of the side.  Examples, with '*' representing the label:

+----------------+
|      ****      |
|                |
|                |
|      ****      |
+----------------+

+----------------+
|                |
|*              *|
|*              *|
|                |
+----------------+

This error occurs for PostScript and raster-type printers.

Comment 13 Olivier Fourdan 2009-09-10 09:42:21 UTC
Created attachment 360470 [details]
New proposed patch

Same logic as previously, this patch seems to produce the expected behavior, ie the labels are places correctly in landscape too.

Both landscape and portrait seem to work.

Comment 15 Tim Waugh 2009-09-15 11:26:03 UTC
My comment #6 is for a different problem then (PS/PDF input already in landscape orientation).  Thanks for the patch; submitted upstream.

Comment 37 RHEL Program Management 2011-05-31 14:13:57 UTC
This request was evaluated by Red Hat Product Management for
inclusion in the current release of Red Hat Enterprise Linux.
Because the affected component is not scheduled to be updated in the
current release, Red Hat is unfortunately unable to address this
request at this time. Red Hat invites you to ask your support
representative to propose this request, if appropriate and relevant,
in the next release of Red Hat Enterprise Linux.

Comment 41 RHEL Program Management 2012-04-02 10:31:54 UTC
This request was evaluated by Red Hat Product Management for inclusion
in a Red Hat Enterprise Linux release.  Product Management has
requested further review of this request by Red Hat Engineering, for
potential inclusion in a Red Hat Enterprise Linux release for currently
deployed products.  This request is not yet committed for inclusion in
a release.