Skip to main content
Skip table of contents

Using SensePageDevice to Perform a Rotation Based on a Filename



The following Postscript can be added to a configuration file or used as a Page Feature. It reads the file name of the input file and rotates it (or doesn't) dependent on the name of the file.

CODE
%!PS

%%% If a marker string is included in the job name, ensure the job is
%%% portrait or landscape, as requested, by rotating if necessary.
%%% We start by defining the strings to look for.


/landscapestr (_land) def %Define Sub-string for landscape rotation

/portraitstr (_port) def %Define Sub-string for portrait rotation


<<
  /SensePageDevice {
    4 dict begin
      serverdict /stdin get 250 string statusdict /filename get exec pop
      /jobname exch def

      % get width and height
      currentpagedevice /CropBox get /MediaBox get
      dup null ne {
        aload pop % x1 y1 x2 y2
        3 -1 roll sub % x1 x2 height
        3 1 roll exch sub % height width
      } {
        pop
        0 0
      } ifelse
      /width exch def
      /height exch def

      % Check if it contains landscapestr.
      jobname landscapestr search {
        pop pop pop
        width height lt {
          /Orientation 1 % Amend this value dependent on rotation requirement. Can also be ExtraOrientation.
        } if
      } {
        pop
      } ifelse

      % Check if it contains portraitstr.
      jobname portraitstr search {
        pop pop pop
        width height gt {
          /Orientation 3 % Amend this value dependent on rotation requirement. Can also be ExtraOrientation.
        } if
      } {
        pop
      } ifelse
    end % local dict
  }
>> setpagedevice


JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.