Location: PHPKode > projects > OpenBizMap > openbizmap/mydata/script/inc_psbase.txt
%%!PS
% odb html2ps functions

/cm {28.5 mul} bind def
/cellspacing 2 def

/page_header_height 1.5 cm def
/page_footer_height 2 cm def

/cfg_show_margins 0 def

/show_image
{
  /img exch def
  /resize_height exch def
  /resize_width exch def
  /height exch def
  /width exch def

  %if
  col_mode 0 eq
  {
    curr_x cellspacing sub curr_y resize_height sub str_height_max add translate
      
    %left
    %nop
    
    %center
    %if
    col_justify_mode 1 eq
    {
      col_end_x act_x sub resize_width sub 2 div cellspacing add 0 translate
    }
    if
    
    %right
    %if
    col_justify_mode 2 eq
    {
      col_end_x act_x sub resize_width sub cellspacing add cellspacing add 0 translate
    }
    if
        
    resize_width resize_height scale
    %show image
    /DeviceRGB setcolorspace 
    <<  % largelogo.eps 
       /ImageType 1  % 1: opaque, 4: make MaskColor color ranges transparent 
       /Decode [ 0 1 0 1 0 1 ]  % change these values to alter brightness/contrast of each color 
    % REMOVE % AT START OF NEXT LINE IF /ImageType 4 
    %   /MaskColor [ 245 255 245 255 245 255 ]  
       /Width width 
       /Height height 
       /ImageMatrix [ width 0 0 height neg 0 height ]
       /BitsPerComponent 8 
       /MultipleDataSources false 
       /Interpolate false 
       /DataSource img 
          /ASCIIHexDecode filter 
          /DCTDecode filter 
    >> 
    image
    
    /act_y act_y str_height_max 2 mul sub def
    /str_height_max resize_height def
  } if
} def

/page_margins
{
  /cfg_page_top_margin exch def
  /cfg_page_bottom_margin exch def
  /cfg_page_left_margin exch def
  /cfg_page_right_margin exch def
}
def

1 cm 1 cm 1 cm 2.5 cm page_margins

/encodefont {
    findfont dup                % Get the old font dict.
    maxlength dict begin        % Make a new one just as big.
    {   1 index /FID ne         % Copy everything but FID.
        {   def }
        {   pop pop }
        ifelse }
    forall
    /Encoding exch def          % Install the new encoding.
    dup /FontName exch def      % New font dict is still current.
    currentdict definefont      % Create the new font.
    end
} bind def

%EncodingPLDE <mix 8859-1 8859-2 win1251>
/EncodingPLDE [
  /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef 
  /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /space /exclam /quotedbl /numbersign /dollar /percent /ampersand /quotesingle 
  /parenleft /parenright /asterisk /plus /comma /hyphen /period /slash /zero /one /two /three /four /five /six /seven /eight /nine /colon /semicolon /less /equal /greater /question /at 
  /A /B /C /D /E /F /G /H /I /J /K /L /M /N /O /P /Q /R /S /T /U /V /W /X /Y /Z /bracketleft /backslash /bracketright /asciicircum /underscore /grave 
  /a /b /c /d /e /f /g /h /i /j /k /l /m /n /o /p /q /r /s /t /u /v /w /x /y /z /braceleft /bar /braceright /asciitilde /.notdef 
  /Euro /.notdef /.notdef /.notdef /.notdef /.notdef 
  /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /Sacute /.notdef /.notdef /Zacute /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef 
  /.notdef /.notdef /sacute /.notdef /.notdef /zacute /uni00A0 /Aogonek /breve /Lslash /currency /Aogonek /Sacute /section /dieresis /Scaron /Scedilla /Tcaron /Zacute /uni00AD 
  /Zcaron /Zdotaccent /degree /aogonek /ogonek /lslash /acute /lcaron /sacute /caron /cedilla /aogonek /scedilla /tcaron /zacute /hungarumlaut /zcaron /zdotaccent /Racute 
  /Aacute /Acircumflex /Abreve /Adieresis /Lacute /Cacute /Ccedilla /Ccaron /Eacute /Eogonek /Edieresis /Ecaron /Iacute /Icircumflex /Dcaron /Dcroat /Nacute /Ncaron /Oacute 
  /Ocircumflex /Ohungarumlaut /Odieresis /multiply /Rcaron /Uring /Uacute /Uhungarumlaut /Udieresis /Yacute /uni0162 /germandbls /racute /aacute /acircumflex /abreve /adieresis 
  /lacute /cacute /ccedilla /ccaron /eacute /eogonek /edieresis /ecaron /iacute /icircumflex /dcaron /dcroat /nacute /ncaron /oacute /ocircumflex /ohungarumlaut /odieresis /divide 
  /rcaron /uring /uacute /uhungarumlaut /udieresis /yacute /uni0163 /dotaccent
] readonly def


%%----------- PAGEMARGINS_PLACEHOLDER -----------------------

/font
{
  /actual_font_number exch def
  
  %switch
  actual_font_number 0 eq {/Helvetica 9 font_def} if
  actual_font_number 1 eq {/Helvetica 7 font_def} if
  actual_font_number 2 eq {/Courier 16 font_def} if
  actual_font_number 3 eq {/Courier-Bold 16 font_def} if
  actual_font_number 4 eq {/Helvetica 12 font_def} if
  actual_font_number 5 eq {/Helvetica 12 font_def} if
  actual_font_number 6 eq {/Helvetica 12 font_def} if
  actual_font_number 7 eq {/Helvetica 12 font_def} if
  actual_font_number 8 eq {/Helvetica 12 font_def} if
  actual_font_number 9 eq {/Helvetica 12 font_def} if
  
%----------- FONT_PLACEHOLDER -----------------------
}
def

%images
%----------- IMAGE_PLACEHOLDER -----------------------

%----------------------------------------

%------------ show_row def --------------
%row

%column
  %col_justify_mode:
  % 0 left
  % 1 center
  % 2 right
  % 3 justify
  
  %col_border_mode:
  % 1 top
  % 2 right
  % 4 bottom
  % 8 left
  
  %col_start_x
  %col_end_x
  %col_text: must be ended with space!
%next columns...

%col_count: number of columns given

%font: optional, ie.:
%/Helvetica 12 font

%------------ example --------------
% %show_row
%  %columns
%    0 15 1 cm 18 cm test_text
%    0 15 18 cm 20.5 cm test_text
%  %col count
%    2
%show_row

%------------ show_row def --------------


%---------------------------------------------------------------------
/page_number_int 0 def
/tmpstr 10 string def
/page_number 0 tmpstr cvs def
/cr_found 0 def

/a4_page_height {29.7 cm} def
/a4_page_width {21.0 cm} def
    
/a4 1 def
/same 1 def
/portrait 1 def
/landscape 2 def

/current_encoding EncodingPLDE def
/actual_font /Helvetica def
/font_heigth 25 def

/page_body_reset
{
  page_left_margin page_body_start moveto
}
def

/check_inline
{
  /command exch def
  /inline_processing 0 def
  (<f0>) command eq {0 font  /inline_processing 1 def} if
  (<f1>) command eq {1 font  /inline_processing 1 def} if
  (<f2>) command eq {2 font  /inline_processing 1 def} if
  (<f3>) command eq {3 font  /inline_processing 1 def} if
  (<f4>) command eq {4 font  /inline_processing 1 def} if
  (<f5>) command eq {5 font  /inline_processing 1 def} if
  (<f6>) command eq {6 font  /inline_processing 1 def} if
  (<f7>) command eq {7 font  /inline_processing 1 def} if
  (<f8>) command eq {8 font  /inline_processing 1 def} if
  (<f9>) command eq {9 font  /inline_processing 1 def} if
  
%----------- COMMAND_PLACEHOLDER -----------------------
  
  (<br>) command eq {/cr_found 1 def /inline_processing 1 def} if
  (<br/>) command eq {/cr_found 1 def /inline_processing 1 def} if
  
  %dummy hidings for variables
  (<[>) command eq {/inline_processing 1 def} if
  (<]>) command eq {/inline_processing 1 def} if
  
  %sets current_encoding to EncodePL or EncodeDE
  (<hint-encoding-plde>) command eq {/current_encoding EncodingPLDE def actual_font dup current_encoding exch encodefont font_heigth scalefont setfont /inline_processing 1 def} if
  %(<hint-encoding-de>) command eq {/current_encoding EncodingDE def actual_font dup current_encoding exch encodefont font_heigth scalefont setfont /inline_processing 1 def} if  
  
  command
  
  (sys_page) command eq {/inline_processing 1 def pop page_number } if
}
def

/page
{
/page_orientation exch def
/page_format exch def

%if
page_number_int 0 gt
{
  showpage
}
if

%page format
% 1 a4
% 2 ???

  %a4 default
  /full_page_height a4_page_height def
  /full_page_width a4_page_width def
  
  %
  %if
  %page_format 2 eq
  %{
  %  /page_height a4_page_height def
  %  /page_width a4_page_width def
  %}
  %if

%page orientation
%1 portrait
%2 landscape
  page_orientation portrait eq
  {
    /same portrait def
    
    %margins
    /page_top_margin cfg_page_top_margin def
    /page_bottom_margin cfg_page_bottom_margin def
    /page_left_margin cfg_page_left_margin def
    /page_right_margin cfg_page_right_margin def
    
    /page_height full_page_height page_top_margin sub page_bottom_margin sub def
    /page_width full_page_width page_left_margin sub page_right_margin sub def
  }
  if
  
  page_orientation landscape eq
  {
    /same landscape def
    
    %margins
    /page_top_margin cfg_page_left_margin def
    /page_bottom_margin cfg_page_right_margin def
    /page_left_margin cfg_page_top_margin def
    /page_right_margin cfg_page_bottom_margin def
    
    /page_width full_page_height page_left_margin sub page_right_margin sub def
    /page_height full_page_width page_top_margin sub page_bottom_margin sub def
    
    page_top_margin page_bottom_margin sub page_width page_left_margin add page_right_margin add translate
    -90 rotate
  }
  if

  %if
  cfg_show_margins 1 eq
  {
    gsave
    
    0.1 setlinewidth
    /x1 page_left_margin def
    /y1 page_bottom_margin def
    /dx page_width def
    /dy page_height def
    
    x1 y1 moveto
    dx 0 rlineto
    0 dy rlineto
    dx neg 0 rlineto
    0 dy neg rlineto
    
    stroke
    
    grestore
  }
  if
  
  /page_header_start page_height page_bottom_margin add def
  /page_footer_start page_footer_height page_bottom_margin add def

  /page_number_int page_number_int 1 add def
  /page_number page_number_int tmpstr cvs def
  /page_body_end -1000 def
  
  page_left_margin page_header_start moveto
  header

  page_left_margin page_footer_start moveto
  footer
  
  /page_body_start page_header_start page_header_height sub def
  /page_body_end page_footer_height page_footer_height add page_header_height add def
  
  page_left_margin page_body_start moveto
  
  
}
def

/str_height_max 0 def
/str_height 0 def

/font_def
{
/font_heigth exch def

  /str_height font_heigth def
  
  %if
  str_height str_height_max gt
  {
    /str_height_max str_height def
  }
  if

  dup
  current_encoding exch encodefont 
  font_heigth scalefont setfont
}
def

/adds  
% string-concat from PS-HTTPD by Anders Karlsson
{ 
  exch dup length 2 index length add string
  dup dup 4 2 roll copy length 4 -1 roll  putinterval
} bind def

%---------------------------------------------------------------------
/show_col
% text must be ended with space!!!
% col_mode 0 - check heigth
% col_mode 1 - show text
% call col_mode start_x end_x text show_col
{
%14 dict begin

/col_text exch def
/col_end_x exch def
/col_start_x exch def
/col_mode exch def
/col_border_mode exch def
/col_justify_mode exch def

%adjust col_end_x when too far
col_end_x page_width gt {/col_end_x page_width cellspacing sub def} if

/str_height_max 0 def
/str_height 0 def
0 font

gsave

  col_start_x font_heigth neg  rmoveto
  /col_line_content () def
  currentpoint
  /curr_y exch def
  /curr_x exch def
  
  /act_x col_start_x def
  /act_y curr_y def
  
  /str_width 0 def
  /tmp_word_count 0 def
  /starting_font_number actual_font_number def
  
  %loop
  {
    col_text ( ) search
    {
      
      /col_text_next_word exch check_inline ( ) adds def
      pop
      /col_text exch def
      
      
      %if
      inline_processing 0 eq
      {
        col_text_next_word stringwidth 
        /str_height exch def
        /str_width exch def
        
        /tmp_word_count tmp_word_count 1 add def
        
        %if
        cr_found 1 eq act_x str_width add col_end_x gt tmp_word_count 1 gt and or
        {
          % col_mode 1 - show text
          %if
          col_mode 1 eq
          {
            
            gsave
              starting_font_number font
              
              %left
              %nop
              
              %center
              %if
              col_justify_mode 1 eq
              {
                col_end_x act_x sub 2 div 0 rmoveto
              }
              if
              
              %right
              %if
              col_justify_mode 2 eq
              {
                col_end_x act_x sub 0 rmoveto
              }
              if
              
              %justify
              %if
              col_justify_mode 3 eq
              {
                %if
                tmp_word_count 2 gt
                {
                  /x_rel {col_end_x act_x sub tmp_word_count 2 sub div} def
                }
                %else
                {
                  /x_rel 0 def
                }
                ifelse
              }
              if
              
              %showing by words
              %loop
              {
                col_line_content ( ) search
                {
                  /show_text exch check_inline ( ) adds def
                  pop
                  /col_line_content exch def
                  
                  %if
                  inline_processing 0 eq
                  {
                    %if
                    col_justify_mode 3 eq
                    {
                      %justify
                      x_rel 0 8#040 show_text widthshow
                    }
                    %else
                    {
                      %right/left/center
                      show_text show
                    }
                    ifelse
                  }
                  if
                }
                %else
                {
                  pop
                  exit
                }
                ifelse
              }
              loop
              
              /starting_font_number actual_font_number def
              
            grestore
            
            0 str_height_max neg rmoveto  
          }
          if
          
          /cr_found 0 def
          /tmp_word_count 1 def
          /col_line_content col_text_next_word def
          /act_x col_start_x str_width add def
          /act_y act_y str_height_max sub def
        }
        %else
        {
          /col_line_content col_line_content col_text_next_word adds def
          /act_x act_x str_width add def
        }
        ifelse
      }
      %else
      {
        /col_line_content col_line_content col_text_next_word adds def
      }
      ifelse
    }
    {
      pop
      
      % col_mode 1 - show text
      %if
      col_mode 1 eq
      {
          gsave
            starting_font_number font
            
            %left
            %nop
            
            %center
            %if
            col_justify_mode 1 eq
            {
              col_end_x act_x sub 2 div 0 rmoveto
            }
            if
                          
            %right
            %if
            col_justify_mode 2 eq
            {
              col_end_x act_x sub 0 rmoveto
            }
            if
            
            %justify
            %nop
            
            %showing by words
            %loop
            {
              col_line_content ( ) search
              {
                /show_text exch check_inline ( ) adds def
                pop
                /col_line_content exch def
                
                %if
                inline_processing 0 eq
                {
                  %right/left/center/justify
                  show_text show
                }
                if
              }
              %else
              {
                pop
                exit
              }
              ifelse
            }
            loop
          
            /starting_font_number actual_font_number def
          grestore
          
          gsave
          
          0.1 setlinewidth
          /x1 col_start_x cellspacing sub page_left_margin add def
          /y1 curr_y str_height_max add def
          /x2 col_end_x cellspacing add page_left_margin add def                    
          /y2 min_y 2 add def %act_y str_height_max 2 div sub def
          /dx x2 x1 sub def
          /dy y2 y1 sub def
          
          %if
          col_border_mode 1 and 0 gt
          {
          x1 y1 moveto
          dx 0 rlineto
          }
          if
          
          %if
          col_border_mode 2 and 0 gt
          {
          x2 y1 moveto
          0 dy rlineto
          }
          if
          
          %if
          col_border_mode 4 and 0 gt
          {
          x2 y2 moveto
          dx neg 0 rlineto
          }
          if
          
          %if
          col_border_mode 8 and 0 gt
          {
          x1 y2 moveto
          0 dy neg rlineto
          }
          if
          
          stroke
          
          grestore
          
          0 str_height_max neg rmoveto
      }
      if
      
      /act_x col_start_x str_width add def
      /act_y act_y str_height_max 2 div sub def
      
      % col_mode 0 - check height
      %if
      col_mode 0 eq
      {
        act_y
      }
      if
      
      exit
    }
    ifelse
  }
  loop



grestore
%end
}
def

%---------------------------------------------------------------------
/show_row
% text must be ended with space!!!
% call start_x end_x text ... col_count show_col
{
%5 dict begin

/col_count exch def
/min_y 10000 def
/max_x 0 def
/min_x 10000 def
%gsave
  
  %duplicate args
  col_count 5 mul copy
  
  %check min_y
  %loop
  /ii col_count def
  {
    %if
    ii 0 eq
    {exit}
    if
    
    /col_text exch def
    /col_end_x exch cellspacing sub def
    /col_start_x exch cellspacing add def
    /col_border_mode exch def
    /col_justify_mode exch def
     
    col_justify_mode
    col_border_mode
    0
    col_start_x
    col_end_x
    col_text
    show_col
    
    /act_y exch def
    %if
    act_y min_y lt
    {
      /min_y act_y def
    }
    if
    
    /ii ii 1 sub def
  }
  loop
  
  %show if valid
  %if
  min_y page_body_end gt
  {
    %loop
    /ii col_count def
    {
      %if
      ii 0 eq
      {exit}
      if
      
      /col_text exch def
      /col_end_x exch cellspacing sub def
      /col_start_x exch cellspacing add def
      /col_border_mode exch def
      /col_justify_mode exch def
       
      col_justify_mode
      col_border_mode
      1
      col_start_x
      col_end_x
      col_text
      show_col
      
      %if
      col_end_x max_x gt
      {
        /max_x col_end_x def
      }
      if
      
      %if
      col_start_x min_x lt
      {
        /min_x col_start_x def
      }
      if

      /ii ii 1 sub def
    } 
    loop
    
    page_left_margin min_y moveto
  }
  %else
  {
    %change page
    
    a4 same page
    
    col_count
    show_row
  }
  ifelse
  
%grestore
%end
}
def

%---------------------------------------------------------------------------

/header
{
%----------- header section here ----------------------
%----------- HEADER_PLACEHOLDER -----------------------
%----------- header section here ----------------------
}
def

/body
{
%----------- body section here ----------------------
%----------- BODY_PLACEHOLDER -----------------------
%----------- body section here ----------------------
}
def

/footer
{
%----------- footer section here ----------------------
%----------- FOOTER_PLACEHOLDER -----------------------
%----------- footer section here ----------------------
}
def

%----------- show -----------------------------------
a4 same page
body

showpage 
Return current item: OpenBizMap