File: rot270.ps

package info (click to toggle)
pstotext 1.6-6
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 204 kB
  • ctags: 244
  • sloc: ansic: 1,583; makefile: 69; sh: 49
file content (84 lines) | stat: -rw-r--r-- 2,788 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
% Copyright (C) 1995, Digital Equipment Corporation.
% All rights reserved.
% See the file pstotext.txt for a full description.
%
% Lectern:
%   PostScript to be prepended to a job to rotate its images by //angle,
%   adjusting the page shape appropriately.  This works only for
%   devices (such as ppmraw) that allow arbitrary imaging areas.

% Last modified on Thu Aug  1 11:36:13 PDT 1996 by mcjones
%      modified on Tue Mar 14 14:54:44 PST 1995 by birrell

4 dict begin
/myDict currentdict def
/angle 270 def

/languagelevel where { pop languagelevel 2 ge } { FALSE } ifelse 
  {
  % Use setpagedevice for level 2 implementations
  /lastW 0 def
  /lastH 0 def
  <<
    /BeginPage {
      //myDict begin
      pop % page number
      currentpagedevice /PageSize get aload pop % stack: W H
%      (H = ) print dup =
%      (W = ) print 1 index = flush
%      (lastH = ) print lastH =
%      (lastW = ) print lastW = flush
      lastH ne exch lastW ne or {
        % /PageSize has changed: rotate it
        <<
          /PageSize [
            currentpagedevice /PageSize get aload pop % stack: W H
            exch % stack: newW newH
            /lastW 2 index def
            /lastH 1 index def
            ]
          >> setpagedevice % calls BeginPage recursively
%        (H := ) print lastH =
%        (W := ) print lastW = flush
        } {
        % Rotate ctm.  Don't do this if we're also adjusting PageSize,
        % because that causes another BeginPage call, which does this.
        currentpagedevice /PageSize get aload pop % stack: width height
        2 div exch 2 div exch % stack: center
        2 copy translate //angle rotate neg exch neg translate
        } ifelse
      end % //myDict
      }
    >> setpagedevice
  } {
  % Use ghostscript specific code for earlier systems
  % flip current frame buffer
    currentdevice getdeviceprops >> /HWSize get
    aload pop exch 2 array astore
    mark exch /HWSize exch currentdevice putdeviceprops pop
  % fix showpage to add a rotation and translation
    /adbFixup {
        currentdevice getdeviceprops >>
        dup /HWSize get aload pop 3 -1 roll
        /HWResolution get aload pop
        % stack: xsize ysize xres yres
        exch 4 -1 roll exch div 72 mul
        % stack: ysize yres xpts
        3 1 roll div 72 mul
        % stack: xpts ypts
        2 div exch 2 div exch
        2 copy translate //angle rotate neg exch neg translate
        } bind odef
    /adbShowpage /showpage load def
    userdict begin /showpage { adbShowpage adbFixup } bind odef end
    adbFixup
  % define new ".setpagesize" that flips its arguments
    statusdict begin
        /adbSet /.setpagesize load def
        /.setpagesize {
          exch adbSet adbFixup
          } bind def
        end
  } ifelse

end % //myDict