Bug 688793 - document pages rotated with Ghostscript, not with Acrobat
Summary: document pages rotated with Ghostscript, not with Acrobat
Status: NOTIFIED FIXED
Alias: None
Product: Ghostscript
Classification: Unclassified
Component: General (show other bugs)
Version: 8.50
Hardware: PC Linux
: P2 normal
Assignee: leonardo
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-07-12 09:08 UTC by Ralph Giles
Modified: 2008-12-19 08:31 UTC (History)
0 users

See Also:
Customer: 242
Word Size: ---


Attachments
patch.txt (2.19 KB, patch)
2006-07-13 13:35 UTC, leonardo
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ralph Giles 2006-07-12 09:08:22 UTC
Customer complains that after converting ps to pdf with Ghostscript 8.50, the
output displays rotated (landscape instead of portrait for a portrait page).
Converting the same file with Acrobat results in the correct orientation.
Comment 1 Ralph Giles 2006-07-12 09:14:25 UTC
Created attachment 2345 [details]
rotate_error.zip

input test file and results from gs and adobe conversion to pdf.
Comment 2 Ralph Giles 2006-07-12 09:40:13 UTC
reproduced with head.
Comment 3 Ralph Giles 2006-07-12 10:21:09 UTC
The document only sets ViewerOrientation, but we're only looking at Orientation
and PageOrientation. We must handle this comment properly, especially as it
takes precedence over the other two.

In the meantime, we fall back to detecting the predominant text direction, which
fails to get the correct orientation for this particular file (reasonably; it's
a graph with more text along the vertical axes). This behaviour can be disabled
by passing -dAutoRotatePages=/None to Ghostscript, but this is not a general
solution.

Calling setorientation in the pagedevice from postscript is the most definitive
fix. Also, getting the ps driver to set Orientation or PageOrientation would
probably also fix it with current Ghostscript.
Comment 4 Raph Levien 2006-07-12 10:55:04 UTC
My analysis:

There are two issues here. First, the document-global viewing_orientation info
isn't being copied into the page-specific info. The following patch seems to me
to be the right thing to do.

Index: src/gdevpdf.c
===================================================================
--- src/gdevpdf.c       (revision 6725)
+++ src/gdevpdf.c       (working copy)
@@ -858,6 +858,9 @@
     page->dsc_info = pdev->page_dsc_info;
     if (page->dsc_info.orientation < 0)
        page->dsc_info.orientation = pdev->doc_dsc_info.orientation;
+    if (page->dsc_info.viewing_orientation < 0)
+       page->dsc_info.viewing_orientation =
+           pdev->doc_dsc_info.viewing_orientation;
     if (page->dsc_info.bounding_box.p.x >= page->dsc_info.bounding_box.q.x ||
        page->dsc_info.bounding_box.p.y >= page->dsc_info.bounding_box.q.y
        )

Second, when the inferred text rotation and the dsc orientation can't match
(i.e. are off by an odd multiple of 90 degrees), precedence is given to the text
rotation. The comment reads: "If not combinable, prefer text rotation". This
logic was committed in svn rev 2836.

My recommendation: apply the patch above, and reverse the precedence so that if
both dsc orientation is set and text rotation is inferred, use the dsc value.
See also bug 687800 for a test case to try.
Comment 5 leonardo 2006-07-13 13:35:50 UTC
Created attachment 2352 [details]
patch.txt

A suggested patch is being tested now.
Comment 6 leonardo 2006-07-13 14:36:39 UTC
Patch to HEAD :
http://ghostscript.com/pipermail/gs-cvs/2006-July/006676.html