%% Polish:                          | English:
% ,,Mi/edzy \TeX-em a drukarni/a''  |``Between \TeX{} and the printing house''
% wersja 1.2, luty 1997 r.          | version 1.2,  February 1997
%--
% Pakiet makr zaprezentowany po raz | Macro package presented on the Polish
% pierwszy na IV konferecji polskiej| TeX Users Group (GUST) IV-th Conference
% Grupy U/zytkownik/ow Systemu TeX  | ``BachoTeX'96''.
% (GUST) ,,Bacho\TeX'96''.          | Corrected  and updated after conference.
% Wersja poprawiona i uzupe/lniona  |
% w stosunku do prezentowanej na    |
% konferencji.
% ------
% Author: Janusz Marian Nowacki
%         86-300 Grudzi/adz
%         ul. /Sniadeckich 82/46
%         tel. (0-51) 218-37, 318-56
%         Poland
%         e-mail: jnowacki@to.onet.pl
%% Wsp/o/lpraca i komentarze:        | Cooperation and comments:
%% Staszek Wawrykiewicz
% Niekt/ore makra i pomys/ly         | Some ideas and macros are borrowed from
% zapo/zyczono z prac B. Jackowskiego| works of B. Jackowski & P. Pianowski.
% i P. Pianowskiego.                 |
%%--------
%% Please report any comments and corrections (e.g., concerning this poor
%% English descriptions and comments ;-)
% ------
% Cel:  obs/luga strony dokumentu    | Purpose: preparation of pages for
% dla cel/ow drukarskich, separacje  | prepress, color separation, crop-marks,
% barwne, monta/z stron na arkuszach | color and gray scale bars,
% drukarskich                        | booklet preparation, etc.
%
% UWAGA: Korzystanie z pakietu       | Use of the package and GhostScript
% i programu GhostScript do podgl/adu| for previewing needs Helvetica font
% wymaga zaistalowania fontu         | have installed. In other case use
% Helvetica. U/zycie opcji \Label\OFF| \Label\OFF toggle.
% nie wymaga posiadania tego fontu.  |
%--
% Opis polece/n - patrz na koniec    | Commands description - see the end
% niniejszego pliku.                 | of this file.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\edef\slashcatcode{\the\catcode`\/}
\catcode`\/12
\catcode`\@=11
%
\newdimen\bigpoint \bigpoint 1bp
\newdimen\Paperwidth
\newdimen\Paperheight
\newcount\Paperwidthcount
\newcount\Paperheightcount
\newdimen\Hoffset
\newcount\Hoffsetcount
\newdimen\Voffset
\newcount\Voffsetcount
\newdimen\LeftMargins
\newcount\LeftMarginscount
\newcount\hsizecount
\newdimen\llmarg
\newdimen\ppmarg
\newdimen\TopMargins
\newcount\gmcount
\newdimen\BottomMargins
\newcount\dmcount
\newdimen\hline
\newcount\Hlinecount
\newdimen\vline
\newcount\Vlinecount
\newcount\Orient
\newcount\sepcount
\newcount\TrapSize
\newcount\MaxTrapSize
\newcount\h@number
\newcount\v@number
\newcount\number@div
\newcount\modresult
%
\def\mod
    #1% dzielna
    #2% dzielnik
    {%
    \modresult = #1
    \number@div = #1
    \divide \number@div by #2
    \multiply\number@div by #2
    \advance \modresult by -\number@div
    }
%
\def\typeout#1{\immediate\write\z@{#1}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Rozszerzanie definicji procedury | extension of PostScript procedure
% PostScript-owej                  |
%
\def\PSprocappend#1#2{% #1 - literal, #2 - (text to be appeneded) tre/s/c dopisywana
  [#1 where {pop #1 load aload pop} if {#2} aload pop] cvx #1 exch def }
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\CYAN    {1 0 0 0}
\def\MAGENTA {0 1 0 0}
\def\YELLOW  {0 0 1 0}
\def\BLACK   {0 0 0 1}
\def\ON      {TRUE }
\def\OFF     {FALSE }
%
\edef\Polski{1}  %% opisy po polsku
\edef\English{2} %% description in English
\def\Lang #1{\edef\@llq{#1}%
\ifx\@llq\Polski
\def\textcolor{Kolor separacji: }
\def\textcolorII{Kompozycja CMYK}
\def\@date{Dnia: }
\def\@file{Plik: }
\else \ifx\@llq\English
\def\textcolor{Plate: }
\def\textcolorII{CMYK model}
\def\@date{Date: }
\def\@file{File: }
\fi \fi}
\def\Language#1{\Lang#1}
%
\def\ScrAngle#1#2#3#4{
\def\CyanAngle{#1 }
\def\MagentaAngle{#2 }
\def\YellowAngle{#3 }
\def\BlackAngle{#4 }}
\ScrAngle{15}{75}{0}{45}
%
\def\ScrFrequency#1#2#3#4{
\def\CyanFrequency{#1 }
\def\MagentaFrequency{#2 }
\def\YellowFrequency{#3 }
\def\BlackFrequency{#4 }}
\ScrFrequency{75}{75}{75}{75}
%
\def\Separate #1{%
 \edef\projectcolor{#1}%
 \ifx\projectcolor\CYAN
 \message{[<\textcolor CYAN>]}
 \def\sepc{false }
 \sepcount=1
 \def\sepcolor{3 }
 \def\Angle {\CyanAngle }
 \def\lpi {\CyanFrequency }
 \else \ifx\projectcolor\MAGENTA
 \message{[<\textcolor MAGENTA>]}
 \def\sepc{false }
 \sepcount=1
 \def\sepcolor{2 }
 \def\Angle {\MagentaAngle }
 \def\lpi {\MagentaFrequency }
 \else \ifx\projectcolor\YELLOW
 \message{[<\textcolor YELLOW>]}
 \def\sepc{false }
 \sepcount=1
 \def\sepcolor{1 }
 \def\Angle {\YellowAngle }
 \def\lpi {\YellowFrequency }
 \else \ifx\projectcolor\BLACK
 \message{[<\textcolor BLACK>]}
 \def\sepc{false }
 \sepcount=1
 \def\sepcolor{0 }
 \def\Angle {\BlackAngle }
 \def\lpi {\BlackFrequency }
 \else \ifx\projectcolor\OFF
 \def\sepc{true }
 \sepcount=2
 \def\sepcolor{4 }
 \def\Angle {\BlackAngle }
 \def\lpi {\BlackFrequency }
 \fi \fi \fi \fi \fi}
%
\def\Dot{abs exch abs 2 copy add 1 gt {1 sub dup mul exch
        1 sub dup mul add 1 sub }{dup mul exch dup mul add 1 exch sub }ifelse }
\def\DotNeg{dup mul exch dup mul add 1 sub}
\def\DotII{dup mul exch dup mul add 1 exch sub}
\def\DotIII{exch abs exch abs   2 copy le { exch } if
        exch 1 sub dup mul exch dup mul add 1 exch sub}
\def\DotIV{180 mul cos exch 180 mul cos add 2 div}
\def\DotV{abs exch abs 2 copy add 0.75 le {dup mul exch dup mul add 1 exch sub}
        { 2 copy add 1.23 le {0.85 mul add 1 exch sub }
        {1 sub dup mul exch 1 sub dup mul add 1 sub }ifelse }ifelse }
\def\CircleBlackWhite{dup mul exch dup mul add 0.6 exch sub abs -0.5 mul}
\def\CircleWhiteBlack{dup mul exch dup mul add 0.6 exch sub abs 0.5 mul}
\def\Diamond{abs exch abs add 1 exch sub}
\def\MicroWaves{/wy exch def
        180 mul cos 2 div wy dup dup dup mul mul sub mul wy add 180 mul cos}
\def\Grid{2 copy abs exch abs gt {exch} if pop 2 mul 1 exch sub 3.5 div}
\def\Lines{pop abs 2 mul 1 exch sub}
\def\Star{abs exch abs 2 copy gt {exch} if 1 sub dup 0 eq {0.01 add} if
        atan 360 div}
\def\Ellipse{dup 5 mul 8 div mul exch dup mul exch add sqrt 1 exch sub }
\def\EllipseII{abs exch abs 2 copy 3 mul exch 4 mul add 3 sub dup 0 lt
        { pop dup mul exch .75 div dup mul add 4 div 1 exch sub }
        { dup 1 gt {pop 1 exch sub dup mul exch 1 exch sub .75 div
        dup mul add 4 div 1 sub } { .5 exch sub exch pop exch pop }
        ifelse } ifelse }
\def\HPExtra{%
        1 add 2 div 3 mul dup floor sub 2 mul 1 sub exch
        1 add 2 div 3 mul dup floor sub 2 mul 1 sub exch
        abs exch abs 2 copy add 1 gt {1 sub dup mul exch
        1 sub dup mul add 1 sub }{dup mul exch dup mul add 1 exch sub }ifelse }
\def\Triangle{%
        2 exch sub exch abs 2 mul sub 3 div}
\def\Random{%
        pop pop usertime srand rand 201 mod 100 div 1 sub}
\def\SawTooth{%
        abs add 2 div}
\def\Triad{%
        1 exch sub exch 1 exch sub sub 2 div}
\def\WhiteSquare{%
        abs exch abs 2 copy gt {pop}{exch pop} ifelse}
\def\BlackSquare{%
        abs exch abs 2 copy gt {exch pop}{pop} ifelse}
\def\Butterfly{%
        add dup mul 5 div}
\def\Moon{%
        2 copy pop 0 le {dup mul exch dup mul add 1 sub}
        {dup mul exch dup mul add 1 exch sub} ifelse}
\def\Pinwheel{%
        2 copy exch 0.001 add atan cvi 60 mod 60 sub abs 60 div 3 1 roll
        dup mul exch dup mul add 1 exch sub add 2 div}
%
\def\Rasterize #1{\edef\raster{#1}}
%
\def\OverprintBlack #1{\edef\overbl{#1}%
\ifx\overbl\ON \def\over@black{true }
\else \ifx\overbl\OFF \def\over@black{false } \fi \fi}
%
\def\OverprintGray #1{\edef\overgr{#1}%
\ifx\overgr\ON \def\over@gray{true }
\else \ifx\overgr\OFF \def\over@gray{false } \fi \fi}
%
\def\OverprintAll #1{\edef\overall{#1}%
\ifx\overall\ON \def\over@all{true }
\else \ifx\overall\OFF \def\over@all{false } \fi \fi}
%
\def\GraySteps #1{\edef\grays{#1}%
\ifx\grays\ON \def\gray@step{true }
\else \ifx\grays\OFF \def\gray@step{false } \fi \fi}
%
\def\ColorBar #1{\edef\colorss{#1}%
\ifx\colorss\ON \def\color@bar{true }
\else \ifx\colorss\OFF \def\color@bar{false } \fi \fi}
%
\def\ColorSteps #1{\edef\colstep{#1}%
\ifx\colstep\ON \def\colorstep{true }
\else \ifx\colstep\OFF \def\colorstep{false } \fi \fi}
%
\def\Label #1{\edef\@label{#1}%
\ifx\@label\ON \def\label{true }
\else \ifx\@label\OFF \def\label{false } \fi \fi}
%
\def\RegMark #1{\edef\@regmark{#1}%
\ifx\@regmark\ON \def\regmark{true }
\else \ifx\@regmark\OFF \def\regmark{false } \fi \fi}
%
\def\Full{komplet} \def\Part{crop}
\def\CropMark #1{\edef\@cropmark{#1}%
\ifx\@cropmark\Full \def\@cropy{true } \def\@crop{true }
\else \ifx\@cropmark\Part \def\@cropy{true } \def\@crop{false }
\else \ifx\@cropmark\OFF \def\@cropy{false } \def\@crop{false }
\fi \fi \fi}
%
\def\Comment#1{\def\@comment{#1}}
%
\def\SEP{
\special{!userdict begin
 /trueunit {0 matrix defaultmatrix matrix currentmatrix matrix invertmatrix
  matrix concatmatrix dtransform dup mul exch dup mul add sqrt} def
 /truebp {trueunit} def
 /truept {72.27 div 72 mul trueunit} def
 /truemm {25.4 div 72 mul trueunit} def
 /truecm {2.54 div 72 mul trueunit} def
%
/ColorSeparations \sepcolor def
/LPI \lpi def
/AngleRaster \Angle def
/Trap@size {\the\TrapSize\space truept} def
/MaxTrapSizeing {\the\MaxTrapSize} def
/Overprint \over@all def
/OverprintBlack \over@black def
/OverprintGray \over@gray def
/OverprintAll \over@all def
/MiterLimit 1 def
/Raster { \raster }  def
/bd {bind def} def
/ld {load def} def
%
/ToCMYK [0 0 0 0 0 0] def
/SaveCMYK [32 {[0 0 0 0 0 0]} repeat] def
%
/@TrapOn false def
%
OverprintAll {/Trap@size 0 store /OverprintBlack false store /OverprintGray false store} if
%
/Trap@size Trap@size 0 gt {Trap@size dup dtransform pop abs store} if
%
/@min {2 copy gt {exch} if pop} bd
/pop2 {pop pop} bd /pop3 {pop pop pop} bd /pop4 {pop pop pop pop} bd
%
/@InStringArray { false exch {2 index eq {not exit} if} forall exch pop } bd
%
/&gsave /gsave ld /&grestore /grestore ld
/&setgray /setgray ld /&fill /fill ld
/&stroke /stroke ld /&eofill /eofill ld
/&image /image ld /&imagemask /imagemask ld
/&setscreen /setscreen ld /&sethsbcolor /sethsbcolor ld
/&show /show ld /&ashow /ashow ld
/&awidthshow /awidthshow ld /&widthshow /widthshow ld
/&kshow /kshow ld /&showpage /showpage ld
/&initgraphics /initgraphics ld
%
systemdict /setpagedevice known
{/&setpagedevice /setpagedevice ld}
{/&setpagedevice {} bd}
ifelse
%
systemdict /colorimage known
{/&colorimage /colorimage ld}
{
/&colorimage { exch
  4 add -3 roll 3 -1 roll mul exch not {exch mul} if
  7 add 8 idiv mul exch {exch mul} if
  /TotalChars exch def  /@error false def
  exch { numprocs copy numprocs {
  exec length dup 0 eq {pop /@error true store}
  {TotalChars exch sub /TotalChars exch store} ifelse} repeat
  @error TotalChars 0 le or { exit } if
  } loop numprocs 1 add {pop} repeat
  } bd
} ifelse
%
/setcmykcolor {ToPixel4 false @SetCMYK} bd
/setgray {1 exch sub 0 0 0 4 -1 roll setcmykcolor} bd
/setrgbcolor {2 index 2 index eq 2 index 2 index eq and
  {pop2 setgray}{ToPixel3 RGB2CMY 0 true @SetCMYK} ifelse} bd
/sethsbcolor {&sethsbcolor currentrgbcolor setrgbcolor} bd
%
/setscreen {pop3 SetScreen} bd
/setcolorscreen {pop3 pop3 pop3 setscreen} bd
%
/ToPixel {255 mul cvi} bd
/ToPixel3 {3 {255 mul cvi 3 1 roll} repeat} bd
/ToPixel4 {4 {255 mul cvi 4 1 roll} repeat} bd
/ToColor {255 div} bd
/SetScreen {LPI AngleRaster /Raster load &setscreen} bd
/RGB2CMY {3 {255 exch sub 3 1 roll} repeat} bd
/@PathSize {&gsave flattenpath pathbbox newpath &grestore 2 index sub 2 1 roll 3 index sub @min 3 1 roll pop2} bd
/@map {
  {exch dup length 0 exch {2 copy 2 copy get 255 exch sub 5 index exch get 255 exch sub put 1 add} repeat}
  {exch dup length 0 exch {2 copy 2 copy get 5 index exch get put 1 add} repeat}
  ifelse 3 -1 roll pop2} bd
%
/@SetCMYK { 5 1 roll 4 copy ToCMYK 0 3 -1 roll put ToCMYK 1 3 -1 roll put
  ToCMYK 2 3 -1 roll put ToCMYK 3 3 -1 roll put 5 -1 roll { } if
  ColorSeparations index ToColor 1 exch sub &setgray pop4} bd
/@CustomColor {1 index @InStringArray
  {ToCMYK 0 0 put ToCMYK 1 0 put ToCMYK 2 0 put ToCMYK 3 0 put ToPixel dup
  pop pop4 1 &setgray}
  {exch pop dup 1 ne {4 {dup 6 -1 roll mul exch} repeat} if pop setcmykcolor}
  ifelse} bd
/@3RGB2Sep { dup length  0 exch
  { 3 index 1 index get 3 index 2 index get 3 index 3 index get
  @RGB2CMY ColorSeparations index
  255 exch sub 8 index 6 index 3 -1 roll put 4pop 1 add
  } repeat 3pop } bd
/@RGB2Sep { dup length 3 idiv dup 0
  ne {dup 0 exch 0 string 0 string def} if 0 exch
  { 1 index 1 index get 2 index 2 index 1 add get 3 index 3 index 2 ad get
  @RGB2CMY ColorSeparations index
  255 exch sub 0 string 6 index 3 idiv 3 -1 roll put 4pop 3 add
  } repeat 2pop 0 string } bd
/@4CMYK2Sep { dup length 0 exch
  {4 index 1 index get 4 index 2 index get 4 index 3 index get 4 index 4 index get
  ColorSeparations index 255 exch sub 8 index 6 index 3 -1 roll put pop4 1 add
  } repeat pop3} bd
/ToCMYK2Sep { dup length 4 idiv dup 0 ne {dup 0 exch store 0 string 0 string def} if
  0 exch
  {1 index 1 index get 2 index 2 index 1 add get 3 index 3 index 2 add get 4 index 4 index 3 add get
  ColorSeparations index 255 exch sub 0 string 6 index 4 idiv 3 -1 roll put pop4 4 add
  } repeat pop2 0 string} bd
/@IsBlackObject { ToCMYK 0 get 255 eq ToCMYK 1 get 0 eq ToCMYK 2 get 0 eq
  ToCMYK 3 get 0 eq and and and } bd
/@IsGrayObject { ToCMYK 0 get 0 gt ToCMYK 0 get 255 lt ToCMYK 1 get 0 eq
  ToCMYK 2 get 0 eq ToCMYK 3 get 0 eq and and and and } bd
/@IsOverprint{
OverprintAll Overprint or
@IsBlackObject OverprintBlack and
@IsGrayObject OverprintGray and
false false and
or or or } bd
%
/@OutputObject {@IsOverprint {ToCMYK ColorSeparations get 0 gt}{true} ifelse} bd
%
/@DoTrap {Trap@size 0 gt {@IsOverprint not ToCMYK ColorSeparations get 0 gt and}
  {false} ifelse} bd
%
/@GetTrapSize {MaxTrapSizeing mul 100 div Trap@size dup idtransform pop abs 2 copy gt
  {exch} if pop} bd
%
/stroke {
@OutputObject
  {
  @DoTrap @TrapOn not and
  {/@TrapOn true store currentlinewidth dup dup @GetTrapSize add setlinewidth
    &stroke setlinewidth /@TrapOn false store }
  { &stroke }
  ifelse
  }
  {newpath}
  ifelse
} bd
%
/gsave {
    ToCMYK SaveCMYK 0 get copy pop
    0 31 lt {0 0 1 add def} if
    &gsave
} bd
%
/grestore {
    0 0 gt {0 0 1 sub def} if
    SaveCMYK 0 get ToCMYK copy pop
    &grestore
} bd
%
/fill {
@OutputObject
  {
  @DoTrap @TrapOn not and
  { /@TrapOn true store &gsave MiterLimit currentmiterlimit lt
    {MiterLimit setmiterlimit} if
    @PathSize @GetTrapSize setlinewidth &stroke &grestore /@TrapOn false store
    }
  if
  &fill
  }
  {newpath}
ifelse
} bd
%
/eofill {
@OutputObject
  {
  @DoTrap @TrapOn not and
  { /@TrapOn true store &gsave MiterLimit currentmiterlimit lt
    {MiterLimit setmiterlimit} if
    @PathSize @GetTrapSize setlinewidth &stroke &grestore /@TrapOn false store
    }
  if
  &eofill
  }
  {newpath}
ifelse
} bd
%
/show {
@OutputObject
    {
    @DoTrap @TrapOn not and
    { /@TrapOn true store &gsave 1 copy false charpath
      MiterLimit currentmiterlimit lt {MiterLimit setmiterlimit} if
      @PathSize @GetTrapSize setlinewidth &stroke &grestore /@TrapOn false store
      }
    if
&show
}
{pop}
ifelse
} bd
%
/ashow {@OutputObject {&ashow} {pop3} ifelse} bd
/widthshow {@OutputObject {&widthshow} {pop4} ifelse} bd
/awidthshow {@OutputObject {&awidthshow} {pop3 pop3} ifelse} bd
/kshow {@OutputObject {&kshow} {pop2} ifelse} bd
%
/@ReadGray {@ReadData true @map} bd
%
/image {
/@saveobj save def
SetScreen
{
} settransfer
ColorSeparations 0 eq
  { &image }
  { currenttransfer 6 1 roll {pop 1} settransfer &image settransfer }
ifelse
@saveobj restore
} bd
%
/imagemask {@OutputObject {&imagemask}{type /dicttype ne {pop4} if}
  ifelse} bd
%
/colorimage {/@saveobj save def SetScreen {
} settransfer
  dup /@ncomp exch def
  1 index {0 index} {1} ifelse 3 add index
  8 ne ColorSeparations 4 eq or {/@ncomp 0 store} if
  @ncomp 0 eq { &colorimage } if @ncomp 1 eq { 2pop image } if @ncomp 3 eq {
  pop {exch exch exch @3RGB2Sep &image}{exch @RGB2Sep load &image}
  ifelse} if save restore} bd
%
/showpage { initmatrix 0 &setgray &showpage initmatrix 0 0 0 1 setcmykcolor } bd
/initgraphics { &initgraphics 0 0 0 1 setcmykcolor } bd
/setpagedevice { &setpagedevice 0 0 0 1 setcmykcolor } bd
%
initmatrix
/letter {} def
SetScreen
0 0 0 1 setcmykcolor
end}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Lokalna zmiana rastra            | Local change of halftone screen for
%%%  #1 - nazwa rastra np \Dot       | different objects on the page
%%%  #2 - lpi  #3 k/at obrotu        | #1 - name (e.g. \Dot), #2 - lpi
%%%  #4 - kolor lub szaro/s/c        | #3 - rotation angle, #4 - color or gray
%%%        (x x x x setcmykcolor, x setgray)
\def\beginLocalRaster#1#2#3#4{
\ifodd\sepcount
    \special{ps:gsave #4 #2 #3 { #1 } &setscreen}
\else
    \special{ps:gsave #4 #2 #3 { #1 } setscreen}
\fi}
\def\endLocalRaster{\special{ps: grestore}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\Orient=1 \def\Landscape{\Orient=2}
\def\Booklet#1#2{\h@number=#1\relax \v@number=#2\relax}
        \Booklet{1}{1}
%
\def\useseparate{\ifodd\sepcount\SEP\else\empty\fi}
\def\main@dimens{%
\LeftMarginscount\LeftMargins \divide\LeftMarginscount by \bigpoint
\hsizecount\hsize \divide\hsizecount by \bigpoint
\BottomMargins=\Paperheight \advance\BottomMargins by-\TopMargins
        \advance\BottomMargins by-\vsize
\dmcount\BottomMargins \divide\dmcount by \bigpoint
\gmcount\TopMargins \divide\gmcount by \bigpoint
\Hoffsetcount\Hoffset \divide\Hoffsetcount by \bigpoint
\Voffsetcount\Voffset \divide\Voffsetcount by \bigpoint
\voffset=297mm
\advance\voffset by -\Paperheight
\advance\voffset by -1in
\advance\voffset by -10mm
\advance\voffset by \TopMargins
\advance\voffset by -\Voffset
\Paperheightcount\Paperheight \divide\Paperheightcount by \bigpoint
\Paperwidthcount\Paperwidth \divide\Paperwidthcount by \bigpoint
}
%
\def\prolog@ps{
\special{!userdict begin \PSprocappend {/bop-hook}
 {/bd {bind def} def /CX {72 2.54 div} def /XX {CX 2 mul} def
 /h@size {\the\Paperwidthcount} bd /v@size {\the\Paperheightcount} bd
 /Skalamm {72 25.4 div  72 25.4 div scale} bd
 /NN {\the\hsizecount} bd  /LM {\the\LeftMarginscount} bd
 /DM {\the\dmcount} bd  /GM {\the\gmcount} bd  /MP {v@size DM sub} bd
 /HO {\the\Hoffsetcount} bd  /VO {\the\Voffsetcount} bd
 /PM {h@size NN sub} bd
 /Vrule {gsave 1 1 0 0 setcmykcolor
   0 CX moveto 0 v@size CX add lineto stroke grestore} bd
 /@Vrule {gsave 0 1 1 0 setcmykcolor .5 setlinewidth
   0 CX moveto 0 v@size CX add lineto stroke grestore} bd
 /Hrule {gsave 1 1 0 0 setcmykcolor CX DM CX add moveto
   h@size CX add DM CX add lineto stroke grestore} bd
 /@Hrule {gsave 0 1 1 0 setcmykcolor .5 setlinewidth
   CX DM CX add moveto h@size CX add DM CX add lineto stroke grestore} bd
 /VVrule {gsave 0 0 1 0 setcmykcolor 0 CX moveto 0 v@size CX add lineto
   stroke grestore} bd
 /HHrule {gsave 0 0 1 0 setcmykcolor CX DM CX add moveto
   h@size CX add DM CX add lineto stroke grestore} bd
 }end}}
%
\def\monthname{\ifcase \month%
   \or I.\or II.\or III.\or IV.\or V.\or VI\or VII%
   \or VIII.\or IX.\or X.\or XI.\or XII.\fi}
%---------------------------------------------------------------
%%--- macros borrowed from `trans.tex' (Jackowski&Pianowski):
\edef\undtranscode{\the\catcode`\_} \catcode`\_11
\newdimen\box_tmp_dim_a
\newdimen\box_tmp_dim_b
\newdimen\box_tmp_dim_c
\newbox\box_tmp
\def\jump_setbox{\aftergroup\after_setbox}
\def\Xflip{%
  \hbox\bgroup
  \def\after_setbox{%
    \box_tmp_dim_a.5\wd\box_tmp
   \setbox\box_tmp
     \hbox{\kern-\box_tmp_dim_a \box\box_tmp \kern\box_tmp_dim_a}%
   \kern\box_tmp_dim_a
    \special{ps: gsave currentpoint currentpoint translate
         [-1 0 0 1 0 0] concat neg exch neg exch translate}%
    \box\box_tmp
    \special{ps: grestore}%
    \kern-\box_tmp_dim_a
    \egroup}%
  \afterassignment\jump_setbox\setbox\box_tmp =
}%
\def\Yflip{%
  \hbox\bgroup
  \def\after_setbox{%
    \box_tmp_dim_a\ht\box_tmp \box_tmp_dim_b\dp\box_tmp
    \box_tmp_dim_c\box_tmp_dim_a \advance\box_tmp_dim_c\box_tmp_dim_b
    \box_tmp_dim_c.5\box_tmp_dim_c
   \setbox\box_tmp\hbox{\vbox{%
     \kern\box_tmp_dim_c\box\box_tmp\kern-\box_tmp_dim_c}}%
   \advance\box_tmp_dim_c-\box_tmp_dim_b
   \setbox\box_tmp\hbox{%
     \special{ps: gsave currentpoint currentpoint translate
         [1 0 0 -1 0 0] concat neg exch neg exch translate}%
     \lower\box_tmp_dim_c\box\box_tmp
     \special{ps: grestore}}%
    \ht\box_tmp\box_tmp_dim_a \dp\box_tmp\box_tmp_dim_b
    \box\box_tmp
    \egroup}%
  \afterassignment\jump_setbox\setbox\box_tmp =
}%
\catcode`\_\undtranscode
%---------------------------------------------------------------
\def\grafika@ps{
\special{!userdict begin \PSprocappend {/bop-hook}
   {
   \the\Orient\space 2 eq
   {/@H {\the\v@number} def /@V {\the\h@number} def}
   {/@H {\the\h@number} def /@V {\the\v@number} def}
   ifelse
   \the\Orient\space 2 eq {
   v@size @V mul CX 2 mul add 0 translate 90 rotate
   } if
   /horver {h@size @H mul v@size @V mul le} bd
   gsave
   /plik {
   \label {
   /Helvetica findfont 6 scalefont setfont
   gsave 1 1 1 1 setcmykcolor (\@file \jobname .tex; \ \
   \@date \the\day .\monthname\the\year\ r. ) show
   \sepcolor 3 eq { ( \textcolor - CYAN) show } if
   \sepcolor 2 eq { ( \textcolor - MAGENTA) show } if
   \sepcolor 1 eq { ( \textcolor - YELLOW) show } if
   \sepcolor 0 eq { ( \textcolor - BLACK) show } if
   \sepcolor 4 eq { ( \textcolorII ) show } if
   horver
   {CX 1.5 mul v@size @V mul CX 1.5 mul add moveto (\@comment) show}
   {40 15 neg moveto (\@comment) show}
   ifelse
   grestore
   } if } bd
 /box {exch dup 0 rlineto exch 0 exch rlineto neg 0 rlineto closepath} bd
 /klin {
   \gray@step {
   gsave 0 .1 1 {0 0 moveto setgray 15 15 box fill 15 0 translate} for
   grestore gsave
   10 {.2 setlinewidth 0 0 moveto 1 setgray 15 15 box stroke 15 0 translate
   } repeat grestore } if
   } bd
 /color@step {
   \colorstep {
   /cyanstep {
   gsave .1 .1 1.1 {0 0 moveto 0 0 0 setcmykcolor 15 15 box fill 15 0 translate} for
   grestore gsave
   10 {.2 setlinewidth 0 0 moveto 1 setgray 15 15 box stroke 15 0 translate
   } repeat grestore } bd
   /magentastep {
   gsave /@y {exch} def .1 .1 1.1 {0 0 moveto 0 @y 0 0 setcmykcolor 15 15 box fill 15 0 translate} for
   grestore gsave
   10 {.2 setlinewidth 0 0 moveto 1 setgray 15 15 box stroke 15 0 translate
   } repeat grestore } bd
   /yellowstep {
   gsave /@y {exch} def .1 .1 1.1 {0 0 moveto 0 @y 0 @y 0 @y 0 setcmykcolor 15 15 box fill 15 0 translate} for
   grestore gsave
   10 {.2 setlinewidth 0 0 moveto 1 setgray 15 15 box stroke 15 0 translate
   } repeat grestore } bd
   horver
   {gsave 305 15 translate 180 rotate yellowstep grestore
   gsave v@size @V mul 10 sub 15 translate 180 rotate cyanstep 155 0 translate magentastep grestore}
   {gsave 5 neg 15 translate 180 rotate yellowstep grestore
   gsave h@size @H mul neg 307 add 15 translate 180 rotate cyanstep 155 neg 0 translate magentastep grestore}
   ifelse
   } if
   } bd
 /color@bar {
   /xx 15 def
   horver
   {/vscale {0 120 v@size @V mul CX 2 mul sub} bd}
   {/vscale {0 120 h@size @H mul CX 2 mul sub} bd}
   ifelse
   /@beg {gsave 0 exch moveto} bd
   /@set {setcmykcolor 15 15 box fill grestore} bd
   /@tr {0 15 translate} bd
   \color@bar {
   vscale {@beg 1 0 0 0 @set} for @tr
   vscale {@beg 0 1 0 0 @set} for @tr
   vscale {@beg 0 0 1 0 @set} for @tr
   vscale {@beg 0 0 0 1 @set} for @tr
   vscale xx sub {@beg 1 1 0 0 @set} for @tr
   vscale xx 2 mul sub {@beg 0 1 1 0 @set} for @tr
   vscale xx 3 mul sub {@beg 1 0 1 0 @set} for @tr
   vscale xx 4 mul sub {@beg 0 0 0 1 @set} for
   } if } bd
 /@Paser {gsave Skalamm .05 setlinewidth 1 1 1 1 setcmykcolor
   0 10 moveto 8.5 10 lineto stroke 0 6 moveto 8.5 6 lineto stroke
   10 0 moveto 10 8.5 lineto stroke 6 0 moveto 6 8.5 lineto stroke
   6 6 2 0 360 arc stroke grestore} bd
 /@Pasery {Paser
   gsave h@size XX add 0 translate 1 neg 1 scale Paser grestore
   gsave 0 v@size XX add translate 1 1 neg scale Paser grestore
   gsave h@size XX add v@size XX add translate 1 neg 1 neg scale Paser grestore
   } bd
 /Paser {gsave Skalamm .05 setlinewidth 1 1 1 1 setcmykcolor
   0 10 moveto 8.5 10 lineto stroke
   10 0 moveto 10 8.5 lineto stroke
   grestore} bd
 /mpaser {gsave Skalamm .05 setlinewidth 1 1 1 1 setcmykcolor
   3 neg 0 moveto 3 0 lineto stroke
   0 3 neg moveto 0 3 lineto stroke
   0 0 2 0 360 arc stroke
   grestore} bd
 /mpasery {
   \regmark {
   gsave h@size @H mul 2 div CX add CX 2 div translate mpaser
   0 v@size @V mul CX add translate mpaser grestore
   gsave CX 2 div v@size @V mul 2 div CX add translate mpaser
   h@size @H mul CX add 0 translate mpaser grestore
   } if } bd
 /Pasery {
   \@cropy {
   \@crop
   {
   @Paser
   gsave h@size @H mul XX add 0 translate 1 neg 1 scale @Paser grestore
   gsave 0 v@size @V mul XX add translate 1 1 neg scale @Paser grestore
   gsave h@size @H mul XX add v@size @V mul XX add translate 1 neg 1 neg
   scale @Paser grestore
   }{
   Paser
   gsave h@size @H mul XX add 0 translate 1 neg 1 scale Paser grestore
   gsave 0 v@size @V mul XX add translate 1 1 neg scale Paser grestore
   gsave h@size @H mul XX add v@size @V mul XX add translate 1 neg 1 neg
   scale Paser grestore
   }
   ifelse } if
   gsave
   horver
   {50 15 moveto plik}
   {h@size @H mul 45 add 35 moveto 90 rotate plik}
   ifelse
   grestore
   } bd
 \the\Orient\space 2 eq {/@VO {VO neg} bd }{/@VO {VO} bd } ifelse
 /full {
   horver
   {gsave h@size @H mul CX add 8 add HO add CX 3 add @VO add translate 0 0 moveto color@bar grestore}
 {gsave h@size @H mul CX add 5 sub CX 10 add v@size @V mul add translate 0 0 moveto 90 rotate color@bar grestore}
   ifelse
   gsave
   HO @VO translate Pasery mpasery
   horver
   {20 35 translate 90 rotate klin color@step}
   {h@size @H mul 125 sub 5 translate klin color@step}
   ifelse
   grestore
   } bd
   full
   grestore
   }end}}
%
\def\@Pages{\one@side}
\def\TwoSide{\def\@Pages{\two@side}}
%
\def\@plain@outputI{
\llmarg 1in \advance\llmarg by -10mm \advance\llmarg by-\LeftMargins
\advance\llmarg by -\Hoffset
\ppmarg -1in \advance\ppmarg by \Paperwidth \advance\ppmarg by 10mm
        \advance\ppmarg by -\LeftMargins \advance\ppmarg by -\hsize
\def\one@side{\hoffset -\llmarg}
%
\def\@str{\ifodd\pageno
        \hoffset\ppmarg\advance\hoffset by \Hoffset \else\hoffset -\llmarg\fi}
\def\@@str{\ifodd\pageno
        \hoffset -\llmarg \else\hoffset\ppmarg\advance\hoffset by \Hoffset\fi}
\def\obrstr{
\ifnum\Orient=2
          \advance\voffset by 11mm
          \advance\voffset by \tw@\Voffset
          \advance\voffset by -\tw@\TopMargins
        \else
          \advance\voffset by 11mm
          \advance\voffset by -\tw@\TopMargins
        \fi
\@str\shipout\Xflip\vbox{\Yflip\vbox{\makeheadline\pagebody\makefootline}}}
\def\notobrstr{%
    \ifnum\Orient=2 \advance\voffset by \tw@\Voffset \fi
    \@@str\shipout\vbox{\makeheadline\pagebody\makefootline}
    \empty}
\def\r@otate{%
    \mod{\pageno}{16}%
    \ifnum\modresult>4
        \ifnum\modresult<13 \obrstr \else \notobrstr \fi
    \else \notobrstr \fi}
\def\plainoutput{\r@otate
        \advancepageno\ifnum\outputpenalty>-20000 \else\dosupereject\fi}
\output{\plainoutput}}
%
\def\@plain@outputII{%
\llmarg 1in \advance\llmarg by -10mm \advance\llmarg by-\LeftMargins
\advance\llmarg by -\Hoffset
\ppmarg -1in \advance\ppmarg by \Paperwidth \advance\ppmarg by 10mm
        \advance\ppmarg by -\LeftMargins \advance\ppmarg by -\hsize
\def\one@side{\hoffset -\llmarg}
\def\two@side{\ifodd\pageno \hoffset -\llmarg
        \else\hoffset\ppmarg\advance\hoffset by \Hoffset\fi}
\def\plainoutput{\@Pages\shipout\vbox{\makeheadline\pagebody\makefootline}
        \advancepageno\ifnum\outputpenalty>-20000 \else\dosupereject\fi}
\output{\plainoutput}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\psPoligraf#1#2{
\Paperwidth=#1 \Paperheight=#2
\useseparate
\main@dimens
\prolog@ps
\grafika@ps
%
\ifnum\v@number>1
\@plain@outputI
\else
\@plain@outputII
\fi
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\ShowGrid{\ifodd\sepcount \empty \else
  \special{!userdict begin \PSprocappend {/bop-hook}
  {gsave
  /show@grid {
  gsave CX 0 translate 0 CX h@size {@Vrule CX 0 translate} for grestore
  gsave 0 v@size DM sub translate 0 CX v@size {@Hrule 0 CX neg translate} for grestore
  0 v@size CX add 4 sub translate
  /@str 3 string def
  /Helvetica findfont 10 scalefont setfont
  0 10 v@size 2.83 div { /@y exch def gsave
        8 @y 2.83 mul neg moveto 0 setgray @y @str cvs show grestore} for
  22 10 translate 0 10 h@size 2.83 div { /@y exch def gsave
        @y 2.83 mul 0 moveto 0 setgray @y @str cvs show grestore} for
  } bd
  HO VO translate show@grid
  grestore}end}
  \fi}
%
\def\RightPages{prawe strony} \def\LeftPages{lewe strony}
\def\MargLines #1{\edef\@gridline{#1}%
\ifx\@gridline\RightPages
\ifodd\sepcount
\empty
\else
\special{!userdict begin \PSprocappend {/bop-hook}
        {/GGridline {gsave CX LM add 0 translate Vrule h@size PM sub 0 translate
        Vrule grestore gsave Hrule 0 MP GM sub translate Hrule grestore } def
        gsave HO 1 add @VO translate GGridline grestore
        }end}
\fi
\else \ifx\@gridline\LeftPages
\ifodd\sepcount
\empty
\else
\special{!userdict begin \PSprocappend {/bop-hook}
        {/Gridline {gsave h@size CX add 0 translate LM neg 0 translate Vrule
        NN neg 0 translate Vrule grestore
        gsave Hrule 0 MP GM sub translate Hrule grestore } bd
        gsave HO 1 add @VO translate Gridline grestore
        }end}
\fi
\else \ifx\@gridline\OFF
\empty
\fi \fi \fi}
%
\def\Vline#1{\ifodd\sepcount \empty \else
        \vline=#1
        \divide\vline by \bigpoint
        \Vlinecount\vline
   \special{!userdict begin \PSprocappend {/bop-hook}
        { /VL {\the\Vlinecount} bd
        gsave CX VL add HO add VO translate VVrule grestore
        }end}
\fi}
\def\Hline#1{\ifodd\sepcount \empty \else
        \hline=#1
        \divide\hline by \bigpoint
        \Hlinecount\hline
   \special{!userdict begin \PSprocappend {/bop-hook}
        { /HL {\the\Hlinecount} bd
        gsave HO MP HL sub VO add translate HHrule grestore
        }end}
\fi}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Lustro (Mirror)
\def\Mirror{\special{!userdict begin \PSprocappend {/bop-hook}
    {[-1 0 0 1 h@size 57 add \the\Hoffsetcount\space 2 mul add 0] concat} end }}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\catcode`\/\slashcatcode
\catcode`\@=12
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%----------- OPIS POLECE/N (COMMANDS DESCRIPTION) ---------------------
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Poni/zsze polecenia _musz/a_     |  Commands below _should be used_
% wyst/api/c przed g/l/ownym       |  before main command \psPoligraf
% poleceniem \psPoligraf           |
%
% Warto/sci domy/slne pakietu:     |  Default values:
%----
\Language\Polski
% j/ezyk komunikat/ow, ew. \English| language toggle (\Polski or \English)
%---
\Hoffset 0mm
%  przesuni/ecie poziome pola      | horizontal shift of printable area
%  zadruku na kartce,              |    (\hoffset not active)
%  komenda \hoffset wy/l/aczona    |
%---
\Voffset 0mm
%  przesuni/ecie pionowe pola      | vertical shift of printable area
%  zadruku na kartce               |    (\voffset not active)
%  komenda \voffset wy/l/aczona    |
%---
\LeftMargins=0mm
% lewy margines stron nieparzystych| left margin of even pages
%---
\TopMargins=0mm
% g/orny margines (bez headline)   | top margins (without headline)
%---
\Comment{ }
% dodatkowy tekst umieszczany      | user comment between top markers
% mi/edzy g/ornymi paserami        |
%---
%\Twoside
%  druk dwustronny (strony lewe    | two-side printing (left and right pages)
%  i prawe)                        |
%\Landscape
% obr/ot ca/lej strony o 90 stopni | rotation of page 90 degrees anticlockwise
\Booklet{1}{1}
% Arkusze drukarskie:              | Plate (booklet) description:
%  #1 - ilo/s/c stron w poziomie   |   #1 - number of pages in columns
%  #2 - ilo/s/c stron w pionie     |   #2 - number of pages in rows
%---
\ScrAngle{15}{75}{0}{45}
% k/at obrotu rastra C M Y K       | screen angle
%---
\ScrFrequency{75}{75}{75}{75}
% liniatura rastra C M Y K         | C M Y K screen frequency (line per inch)
%---
\Rasterize\Dot
% wyb/or rodzaju rastra:           | select halftone screen:
       % \Dot         \Grid        \CircleBlackWhite   \Random
       % \DotII       \Lines       \CircleWhiteBlack   \SawTooth
       % \DotIII      \Star        \WhiteSquare        \Triad
       % \DotIV       \Ellipse     \BlackSquare        \Butterfly
       % \DotV        \EllipseII   \MicroWaves
       % \DotNeg      \HPExtra     \Moon
       % \Diamond     \Pinwheel    \Triangle
%---
\TrapSize=0
% wielko/s/c zalewki w punktach    | trap size in pt (not related for PK
% (nie dot. font/ow PK i linii     | fonts and TeX rules)
%  TeX-owych)
%---
\MaxTrapSize=5
% maksymalne zwi/ekszenie obiektu  | percentage of maximal trap overlap
% przez zalewk/e (w procentach)
%---
\OverprintGray\ON
% naddruk obiekt/ow szarych        | grey overprint
%---
\OverprintBlack\ON
% naddruk obiekt/ow czarnych       | black overprint
%---
\OverprintAll\OFF
% naddruk wszystkich obiekt/ow     | all object overprint (removes \TrapSize)
% (likwiduje \TrapSize)            |
%---
\GraySteps\OFF
% wy/l/aczenie paska skali szaro/sci| grey steps scale toggle
%---
\ColorSteps\OFF
% wy/l/aczenie pask/ow skali       | color steps scale toggle
% kolor/ow
%---
\ColorBar\OFF
% wy/l/aczenie paska barw          | color bar toggle
% (brudziki)
%---
\Label\ON
% opis strony, \Label\OFF nie wymaga| description of page on margins, use
% posiadania fontu Helvetica        | of \Label\OFF doesn't need Helvetica
%                                   | font to be installed
%---
\RegMark\ON
% w/l/aczenie paser/ow              | registration `middle-border' mark toggle
% nienaro/znikowych
%---
\CropMark\Full
% wyb/or:                           | choose:
% ,,tylko linie ci/ecia''=\Part,    |  `only cropmarks'=\Part,
% ,,linie ci/ecia + pasery''=\Full, |  `crop + registration marks'=\Full
% lub \OFF - wy/l/aczone            |  `not used'=\OFF
%---
\Separate\OFF
% w/l/aczenie mechanizmu separacji  | color separation toggle:
% kolor/ow                          | \CYAN, \MAGENTA, \YELLOW, \BLACK or \OFF
% \CYAN \MAGENTA \YELLOW \BLACK     |
% \OFF - bez separacji              |
%---
%%% \psPoligraf{#1}{#2}             | main procedure switch
% #1 - szeroko/s/c kartki;          | #1 - horizontal size of sheet
% #2 - wysoko/s/c kartki            | #2 - vertical size of sheet
%---
%\Mirror
% lustrzane odbicie ca/lej strony    | mirror switch
%==========
% polecenia do u/zycia po \psPoligraf| the following commands can be used only
% (tylko do wy/swietlania):          | after \psPoligraf (only for previewing,
%                                    | have no effect when printing):
%--
%\Hline{#1} \Vline{#1}
% linie pomocnicze w odleg/lo/sci #1 | user additional rules at distance #1
%---
%\ShowGrid
% siatka linii co 10mm               | grid lines (one line per 10mm)
%---
\MargLines\OFF
% linie margines/ow stron:           | margin lines for a page:
%  \OFF - wy/l/aczone                |   \OFF - not used
%  \RightPages - dla stron `prawych' |   \RightPages - for `right' pages
%  \LeftPages - dla stron `lewych'   |   \LeftPages - for `left' pages
%---------------------------------------------------------------------
\endinput
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Lokalna zmiana rastra r/o/znych | Local change of halftone screen for
%%% obiekt/ow na stronie            | different objects on a page
%
% \beginLocalRaster{#1}{#2}{#3}{#4}
%   #1 - nazwa rastra np \Dot       | #1 - name of the type of halftone screen
%   #2 - liniatura rastra w lpi     | #2 - screen frequency (lines per inch)
%   #3 - k/at obrotu rastra         | #3 - screen angle
%   #4 - kolor lub szaro/s/c, np.:  | #4 - color or gray, e.g.:
%                 {x x x x setcmykcolor} or {x setgray}
%  . . .
% \endLocalRaster
%
% Przyk/lad                         | Example:
%
% \beginLocalRaster{\Dot}{20}{45}{0 .5 .5 0 setcmykcolor}
% \hrule width\hsize height20mm
% \endLocalRaster

