Skip to main content
Skip table of contents

(v13) Simple imposition example: 2 across

This page applies to Harlequin v13.1r0 and later; both Harlequin Core and Harlequin MultiRIP.

This example uses a number of RIP extensions, which will be explained in the rest of this chapter, after the example has been described.

From version 7.0 the 2-across page feature is no longer supplied. The same effect can be used by selecting the 2-across Imposition setup from the Page Setup dialog box.

First, a global dictionary is set up to keep a running page count and to store some constants. Though the page feature implements two pages side by side, we could form any grid of abutting input pages by varying the constants N-Across and N-Down .

            currentglobal true setglobal
            userdict /SW-Page-Imposition 6 dict put setglobal
            userdict /SW-Page-Imposition get begin
            /N-Across 2 def % number of pages in the x direction of the page
            /N-Down 1 def % number of pages in the y direction of the page
            /PageCount 0 def % keep our own record of number of pages seen
            /N-Total N-Across N-Down mul def % for convenience
            /PageDeactivation 2 def % constant which triggers device
            % deactivation when passed to EndPage; defined for clarity

Then we set our own BeginPage and EndPage procedures (using the setpagedevice operator) which are used to make changes between pages. The page device extension Scaling (see (v13) Configuring the page device) is used to multiply up the page size requested by the number of pages in each direction, and then each page is scaled back down again and translated into its position in the grid. ExtraOrientation is a RIP extension which behaves like Orientation (again, see (v13) Configuring the page device) and is used here to turn the page through 90 degrees.

            currentpagedevice begin
              % reset /Scaling using its current value and the values of
              % N-Down and N-Across
              /Scaling [
                Scaling null eq {
                  //N-Across //N-Down
                  Scaling 0 get //N-Across mul Scaling 1 get //N-Down mul
                } ifelse
            /ExtraOrientation ExtraOrientation 1 sub dup 0 lt { pop 3 } if
            /BeginPage { % showpagecount on stack
              % this procedure is executed at the beginning and just
              % after each showpage, that is at the start of each new
              % page. pop
                //SW-Page-Imposition begin currentpagedevice /PageSize get aload pop
                % scale down by the number of pages we have to fit in
                1 //N-Across div 1 //N-Down div scale
                % calculate the translation for this page on the output PageCount //N-Total mod
                dup //N-Across mod 3 index mul
                exch //N-Across idiv //N-Down 1 sub exch sub 2 index mul translate
                % clip to the area occupied by this input page; because
                % we have already done the translation, this is in the
                % page’s coordinate system
                %| w h
              0 0 4 2 roll rectclip end
            } bind

The EndPage procedure decides whether to output the page. It is called near the beginning of each showpage and (loosely speaking) at the end of the job (known as device deactivation ). If it returns true, the pages accumulated so far will be output, otherwise not. We want output to occur when a full sheet of input pages is ready, and for any leftover pages at the end.

  /EndPage { % showpagecount code -> bool exch pop
    //SW-Page-Imposition /PageCount 2 copy get
    4 -1 roll //PageDeactivation eq {
      % here on device deactivation deal with the final
      % incomplete sheet
      //N-Total mod 0 ne % the boolean result that
      % EndPage has to produce
      3 1 roll 0 put % restart counter
      % here on normal showpage
      1 add
      dup //N-Total mod
      4 1 roll put % increment page counter
      0 eq % deliver page if it is complete
    } ifelse
  } bind
  end % currentpagedevice
  /Imposition true % RIP extension
  >> setpagedevice
  end % SW-Page-Imposition
  userdict /SW-Page-Imposition undef % for the sake of tidiness.

The following code paints some pages:

            %%PlateColor: Cyan
            0.9 setgray clippath fill
            0.5 setgray
            20 20 300 300 rectfill showpage
            %%PlateColor: Magenta
            0.7 setgray clippath fill
            0.5 setgray
            120 120 400 400 rectfill showpage
            %%PlateColor: Yellow
            0.9 setgray clippath fill
            0.5 setgray
            180 180 400 400 rectfill showpage
            %%PlateColor: Black
            0.7 setgray clippath fill
            0.5 setgray
            280 280 200 500 rectfill showpage
            %%PlateColor: Grass Green
            0.9 setgray clippath fill
            0.5 setgray
            320 320 200 500 rectfill showpage.
JavaScript errors detected

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

If this problem persists, please contact our support.