Postscript: border 
Author Message
 Postscript: border

Hi,

I have problems with the right and the left border of the paper.
A generated PS-File has the following Pre-File. The printed Paper is not
completely printed at the right site of the paper.
Can anybody tell me where in the following lines the border is adjusted?

Alex

%!PS-ADOBE-2.0 EPSF-2.0
%%Creator: Meto PM30
%%Title: temp.ps
/metopage save def
%standard defines for Meto PM30 postscript output

% HISORY :
% 94/05/28    CS     Version 94/04/22 : History introduced
%                    rotated text : changes in : prepfont,printtext,
%                                                printpreisfeld
%                    rotate whole fields : new routine rotate_field !!

/scratch 256 string def

% -------------------------------------------------------------------------
% routines to calculate cm etc to point
/cm {72 mul 2.57 div} def
/mm {72 mul 25.70005 div} def
% pt means point
/pt {} def

% -------------------------------------------------------------------------
% color support

% routine to set foreground color
/set_fgcolor
{
fg_color setrgbcolor

Quote:
} def    % set_fgcolor

% -------------------------------------------------------------------------
% routine to set background color
/set_bgcolor
{
bg_color setrgbcolor

Quote:
} def    % set_bgcolor

% -------------------------------------------------------------------------
% default foreground color is black
/black_color {0.0 0.0 0.0} def
/white_color {1.0 1.0 1.0} def
/fg_color {black_color} def
set_fgcolor

% default background color is white
/bg_color {1.0 1.0 1.0} def

% end of color support

% sheet format
%/dina4_hoehe 842 45 sub def
/dina4_hoehe {29.7 cm 1.6 cm sub} def
/dina3_hoehe {41.9 cm} def

% default is dina4
/blatt_hoehe dina4_hoehe def
/blatt_xoffset 0.0 def

% -------------------------------------------------------------------------
% default is outline off, shadow off, underline off
/outline 0 def
/shadow 0 def
/shadow_shift 0 def
/underline 0 def
/strikeout 0 def

% -------------------------------------------------------------------------
% default is a shadow width of 1/10 height of font
/shadow_factor 0.025 def

% -------------------------------------------------------------------------
% default is a shadow counter of 10 times the font
/shadow_counter 10 def

% -------------------------------------------------------------------------
% default is portrait mode
blatt_xoffset blatt_hoehe translate
/portrait_mode 1 def
/landscape_mode 0 def

% -------------------------------------------------------------------------
% because the origin is in the upper left corner
/xmul 1.0 def
/ymul -1.0 def

% -------------------------------------------------------------------------
% set landscape mode
/landscape_modus
{
portrait_mode 1 eq           % if portrait_mode
       {
       /portrait_mode 0 def
       /landscape_mode 1 def
/xmul -1.0 def
/ymul -1.0 def
       90 rotate
       } if

Quote:
} def

% -------------------------------------------------------------------------
% set portrait mode
/portrait_modus
{
landscape_mode 1 eq           % if landscape_mode
       {
       /portrait_mode 1 def
       /landscape_mode 0 def
       -90 rotate
/xmul 1.0 def
/ymul -1.0 def
       } if

Quote:
} def

% -------------------------------------------------------------------------
% set height of paper
/paper_height
{
/new_xoffset exch def
/new_height exch def

% first we have to bring the origin of the coordinate system back to the
% postscript default point in the lower left corner of the sheet

landscape_mode 1 eq           % if landscape_mode
        {
        portrait_modus             % first go to portrait modus
        blatt_xoffset neg blatt_hoehe neg translate % then we are were we
wanted to be
        /blatt_xoffset new_xoffset def  % set the new sheet height
        /blatt_hoehe new_height def  % set the new sheet height
        blatt_xoffset blatt_hoehe translate     % origin to the upper left
corner
        landscape_modus            % thats what we started with
        }
        {              % even easier in portrait mode
        blatt_xoffset neg blatt_hoehe neg translate % then we are were we
wanted to be
        /blatt_xoffset new_xoffset def  % set the new sheet height
        /blatt_hoehe new_height def  % set the new sheet height
        blatt_xoffset blatt_hoehe translate     % origin to the upper left
corner
        }
        ifelse
%debugging the sheet lenght in interpreter mode :
%blatt_hoehe
%pstack
%pop

Quote:
} def

% -------------------------------------------------------------------------
% default line width 0.05 cm
/default_linewidth {0.05 cm} def
/linewidth default_linewidth def
/strikelinewidth default_linewidth def

% -------------------------------------------------------------------------
% routine to find, scale , rotate (angle) and set font f with size sz
/prepfont
{ /angle exch def
  /f exch def
  /ar exch def    % aspect ratio
  /local_sz exch def

  f findfont

  angle matrix rotate
% scaling height of font by 1.0
% and width by 0.01 * aspect ratio
  local_sz 0.0096 mul ar mul local_sz 1.0 mul matrix scale
  matrix concatmatrix
  makefont
  setfont

Quote:
} def            % prepfont

% -------------------------------------------------------------------------
% routine to print text in outline mode
/show_outline
{
  gsave
       currentlinewidth 2 mul
       setlinewidth
       dup
       true charpath stroke
  grestore
  gsave
       set_bgcolor
       true charpath fill
  grestore

Quote:
} def          % show_outline

/set_half_color
{
       currentrgbcolor
      /b  exch  def
      /g  exch  def
      /r  exch  def
% shadow darker than text
%        r 2 div
%        g 2 div
%        b 2 div
% shadow brighter than text
       r b add g add 0 eq
  {r 0.5 add
   g 0.5 add
   b 0.5 add}
  {
   r 0 eq
     {r}
     {r 1.0 r sub 2 div add}
     ifelse
   g 0 eq
     {g}
     {g 1.0 g sub 2 div add}
     ifelse
   b 0 eq
     {b}
     {b 1.0 b sub 2 div add}
     ifelse}
   ifelse
       setrgbcolor
Quote:
} def

% -------------------------------------------------------------------------
% routine to print text in shadow mode
/show_shadow
{
  gsave
       currentrgbcolor
      /b  exch  def
      /g  exch  def
      /r  exch  def
       set_half_color
       shadow_shift shadow_shift neg rmoveto
       % print shadow text in shadow_counter steps
       /shadowsteps shadow_counter def
       shadowsteps
    {
    dup show
    shadow_shift shadowsteps div strlen add neg
    shadow_shift shadowsteps div rmoveto
    }
       repeat
       r g b setrgbcolor
%       shadow_shift strlen add neg shadow_shift rmoveto
       show
  grestore

Quote:
} def          % show_shadow

% -------------------------------------------------------------------------
% routine to show the text in different styles
/myshow
{
   % calculate effective length for shadow text
   %stand vorher in printtext
   dup
   /strlen exch stringwidth pop def
   /strlen_eff strlen def
   shadow 1 eq    % if shadow than increase strlen_eff by a factor of height
   {
   /current_font_height currentfont /FontMatrix get 3 get 1000 mul def
   /strlen_eff strlen current_font_height shadow_factor mul add def
   % shadow shift we need later when actually printing text
   /shadow_shift {current_font_height shadow_factor mul} def
   } if
underline 1 eq                                   % if underlined
   {
   currentpoint /ycur exch def /xcur exch def   % store current point
   }
   if
strikeout 0 gt                                   % if strikeout > 0
   {
   currentpoint /ycur exch def /xcur exch def   % store current point
   }
   if
outline 1 eq                                     % if outlined
 { show_outline }
 { shadow 1 eq                            % else if shadow
   { show_shadow }
   { show }                        % normal text
   ifelse
 }
 ifelse
underline 1 eq                                   % if underlined
   {
   % determine underline position :

   % this is the current font height :
   /currentfontheight currentfont /FontMatrix get
        3 get
        1000 mul def
   % print the line 0.05 * currentfontheigt below the baseline
   /underlinepositionfactor 0.05 def
   /upos currentfontheight underlinepositionfactor mul neg def

   % determine the underline thickness :

   % print the line with thickness 0.02 * currentfontheigt
   /underlinethicknessfactor 0.02 def
   /uthick currentfontheight underlinethicknessfactor mul neg def

   % now print the  line :

   shadow 0 eq
   {
        xcur xmul mul
        ycur upos add ymul mul
        xcur strlen add xmul mul
        ycur upos add ymul mul
        uthick                 line
   } if
   shadow 1 eq
   {
        xcur xmul mul
        ycur upos add ymul mul
        xcur strlen add xmul mul
        ycur upos add ymul mul
        uthick                 shadow_line
   } if
   }
   if
strikeout 0 gt                                   % if strikeout > 0
   {

   % determine underline position :

   % the strikeout line shall not reach the full font height
   /strikeout_correction 0.75 def
   % this is the current font height :
   /currentfontheight currentfont /FontMatrix get
        3 get
        1000 mul
        strikeout_correction mul def

   % now print the  line :

   strikeout 1 eq      % from upper left to lower right
      {
      xcur xmul mul
      ycur currentfontheight add ymul mul
      xcur strlen add xmul mul
      ycur ymul mul
      strikelinewidth                 line
      } if
   strikeout 2 eq      % from lower left to upper right
      {
      xcur xmul mul
      ycur ymul mul
      xcur strlen add xmul mul
      ycur currentfontheight add ymul mul
      strikelinewidth                 line
      } if
   strikeout 3 eq
      {
      xcur xmul mul
      ycur ymul mul
      xcur strlen add xmul mul
      ycur currentfontheight add ymul mul
      strikelinewidth                 line
      xcur xmul mul
      ycur currentfontheight add ymul mul
      xcur strlen add xmul mul
      ycur ymul mul
      strikelinewidth                 line
...

read more »



Sun, 29 Feb 2004 23:29:28 GMT  
 Postscript: border
Quote:

> Hi,

> I have problems with the right and the left border of the paper.
> A generated PS-File has the following Pre-File. The printed Paper is not
> completely printed at the right site of the paper.
> Can anybody tell me where in the following lines the border is adjusted?

> Alex

> %!PS-ADOBE-2.0 EPSF-2.0
> %%Creator: Meto PM30
> %%Title: temp.ps
> /metopage save def
> %standard defines for Meto PM30 postscript output

> % HISORY :
> % 94/05/28    CS     Version 94/04/22 : History introduced
> %                    rotated text : changes in : prepfont,printtext,
> %                                                printpreisfeld
> %                    rotate whole fields : new routine rotate_field !!

> /scratch 256 string def

> % -------------------------------------------------------------------------
> % routines to calculate cm etc to point
> /cm {72 mul 2.57 div} def
> /mm {72 mul 25.70005 div} def
> % pt means point
> /pt {} def

<-- snip a lot of code -->

Try 2.54 instead of 2.57
HIH

Bert



Mon, 01 Mar 2004 18:55:15 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. postscript border cut

2. Fancy Borders in Postscript

3. want curly borders for certificate

4. USA and state border outlines wanted

5. Border Problem

6. left border between multiple pages?

7. a filled gray box with black border

8. border on multiple-page output

9. DIV border

10. shared borders

11. add border to given file

12. Filling polygon with stroked border...

 

 
Powered by phpBB® Forum Software