⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gs_pdf.ps

📁 遗传算法工具箱 希望高手指点 GATOOLS
💻 PS
📖 第 1 页 / 共 2 页
字号:
%    Copyright (C) 1994, 1996 Aladdin Enterprises.  All rights reserved.
% 
% This file is part of Aladdin Ghostscript.
% 
% Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author
% or distributor accepts any responsibility for the consequences of using it,
% or for whether it serves any particular purpose or works at all, unless he
% or she says so in writing.  Refer to the Aladdin Ghostscript Free Public
% License (the "License") for full details.
% 
% Every copy of Aladdin Ghostscript must include a copy of the License,
% normally in a plain ASCII text file named PUBLIC.  The License grants you
% the right to copy, modify and redistribute Aladdin Ghostscript, but only
% under certain conditions described in the License.  Among other things, the
% License requires that the copyright notice and this notice be preserved on
% all copies.

% gs_pdf.ps
% ProcSet for PostScript files created by the PDF to PostScript converter.
% This ProcSet requires only a Level 1 interpreter.

% pdf2ps copies this file from %BEGIN to the end.

%BEGIN
mark				% patches
/currentglobal { false }
/setglobal { pop }
/packedarray { array astore readonly }
/setcmykcolor
 { 1 exch sub
   4 -1 roll 1 exch sub 1 index mul
   4 -1 roll 1 exch sub 2 index mul
   4 -2 roll exch 1 exch sub mul
   setrgbcolor
 }
/.copydict
 { dup 3 -1 roll { put dup } forall pop }
/.dicttomark
 { counttomark 2 idiv dup dict begin { def } repeat pop currentdict end }
/.knownget
 { 2 copy known { get true } { pop pop false } ifelse }
counttomark 2 idiv
 { 1 index where { pop pop pop } { bind executeonly def } ifelse
 } repeat pop

currentglobal true setglobal

% Define pdfmark.  Don't allow it to be bound in.
% Also don't define it in systemdict, because this leads some Adobe code
% to think this interpreter is a distiller.
% (If this interpreter really is a distiller, don't do this.)
systemdict /pdfmark known not
 { userdict /pdfmark { cleartomark } bind put } if

% This ProcSet is designed so that it can be used either to execute PDF
% (the default) or to convert PDF to PostScript.  See ! and ~ below.

userdict /GS_PDF_ProcSet 119 dict dup begin

% ---------------- Abbreviations ---------------- %

/bdef { bind def } bind def

% ---------------- Operator execution ---------------- %

% We record "operator" names in a dictionary with their argument counts,
% so that they can easily be redefined later to write PostScript in
% addition to (or instead of) being executed.

/numargsdict 100 dict def
/!		% <procname> <proc> <numargs> ! -
 { //numargsdict 3 index 3 -1 roll put def
 } bdef
/~		% <procname> <opname> <numargs> ~ -
 { exch cvx 1 packedarray cvx exch !
 } bdef

% ---------------- Graphics state stack ---------------- %

% PDF adds a number of parameters to the graphics state.
% We implement this by pushing and popping a dictionary
% each time we do a PDF gsave or grestore.
% The keys in this dictionary are as follows:
%	self			% identifies the dictionary as one of ours
%	Show
%	TextOrigin		% origin of current line, in text space
%	TextSaveMatrix		% matrix at time of BT
% (The following correspond directly to PDF state parameters.)
%	FillColor
%	FillColorSpace
%	StrokeColor
%	StrokeColorSpace
%	TextSpacing
%	TextHScaling
%	Leading
%	TextFont
%	TextMatrix
%	TextRise
%	TextRenderingMode
%	WordSpacing

/nodict 1 dict def
nodict /self { //nodict } executeonly put
nodict readonly pop

/beginpage
 { //nodict 20 dict .copydict begin graphicsbeginpage textbeginpage
 } bdef
/endpage
 { showpage end
 } bdef

/graphicsbeginpage { initgraphics  0 g  0 G } bdef

/gput		% <value> <key> gput -
 { exch currentdict //nodict eq { /self dup load end 5 dict begin def } if
		% If we're in a Level 1 system, we need to grow the
		% dictionary explicitly.
   currentdict length currentdict maxlength ge %eq
    { currentdict dup length 3 mul 2 idiv 1 add dict .copydict end begin 
    }
   if def
 } bdef

/q_
 { gsave //nodict begin
 } bdef
/q /q_ load 0 !
% Some PDF files have excess Q operators!
/Q_
 { currentdict /self .knownget { exec //nodict eq { end grestore } if } if
 } bdef
/Q /Q_ load 0 !

% ---------------- Graphics state parameters ---------------- %

/d /setdash 2 ~
/i /setflat 1 ~
/j /setlinejoin 1 ~
/J /setlinecap 1 ~
/M /setmiterlimit 1 ~
/w /setlinewidth 1 ~

% ---------------- Color setting ---------------- %

/fcput		% <color> <colorspace> fcput -
 { /FillColorSpace gput /FillColor gput
 } bdef
/scput		% <color> <colorspace> scput -
 { /StrokeColorSpace gput /StrokeColor gput
 } bdef

/csdevgray [/DeviceGray] readonly def
/csdevrgb [/DeviceRGB] readonly def
/csdevcmyk [/DeviceCMYK] readonly def

/CSdict 11 dict dup begin
  /DeviceGray { 0 exch } bdef
  /DeviceRGB { [0 0 0] cvx exch } bdef
  /DeviceCMYK { [0 0 0 1] cvx exch } bdef
  /Indexed
   { dup 1 get csset exch pop
     dup 2 index 1 get eq
      { pop }
      { exch 4 array copy dup 1 4 -1 roll put }
     ifelse 0 exch
    } bdef
  /setcolorrendering where
   { pop
     /CalGray
      { 1 get dup /Gamma .knownget
	 { dup length 1 add dict .copydict
	   dup /DecodeA 4 -1 roll /exp load 2 packedarray cvx put
         }
	if /CIEBasedA exch 2 array astore 0 exch
      } bdef
     /CalRGB
      { 1 get dup /Gamma known 1 index /Matrix known or
	 { dup length 2 add dict .copydict
	   dup /Matrix .knownget { 1 index /MatrixABC 3 -1 roll put } if
	   dup /Gamma .knownget
	    { [ exch { /exp load 2 packedarray cvx } forall
	      ] 1 index /DecodeABC 3 -1 roll put
	    }
	   if
         }
	if /CIEBasedABC exch 2 array astore [0 0 0] cvx exch
      } bdef
     /CalCMYK { pop //csdevcmyk csset } bdef	% not supported yet
   }
   { /CalGray { pop //csdevgray csset } bdef
     /CalRGB { pop //csdevrgb csset } bdef
     /CalCMYK { pop //csdevcmyk csset } bdef
   }
  ifelse
end def
/csset			% <cspace> csset <color> <cspace>
 { dup dup type /nametype ne { 0 get } if //CSdict exch get exec
 } bdef

/g { //csdevgray fcput } 1 !
/G { //csdevgray scput } 1 !
/rg { 3 array astore cvx //csdevrgb fcput } 3 !
/RG { 3 array astore cvx //csdevrgb scput } 3 !
/k { 4 array astore cvx //csdevcmyk fcput } 4 !
/K { 4 array astore cvx //csdevcmyk scput } 4 !
/cs { csset fcput } 1 !
/CS { csset scput } 1 !
% We have to break up sc according to the number of operands.
/sc1 { /FillColor gput } 1 !
/SC1 { /StrokeColor gput } 1 !
/sc3 { /FillColor load astore pop } 3 !
/SC3 { /StrokeColor load astore pop } 3 !
/sc4 { /FillColor load astore pop } 4 !
/SC4 { /StrokeColor load astore pop } 4 !

% ---------------- Color installation ---------------- %

% Establish a given color (and color space) as current.
/setfillcolor { FillColor FillColorSpace setgcolor } def
/setstrokecolor { StrokeColor StrokeColorSpace setgcolor } def
/CIdict mark			% only used for Level 1
  /DeviceGray 1   /DeviceRGB 3   /DeviceCMYK 4
  /CIEBaseA 1   /CIEBaseABC 3   /CIEBasedDEF 3   /CIEBaseDEFG 4
.dicttomark def
/Cdict 11 dict dup begin	% <color...> <colorspace> -proc- -
  /DeviceGray { pop setgray } bdef
  /DeviceRGB { pop setrgbcolor } bdef
  /DeviceCMYK { pop setcmykcolor } bdef
  /CIEBasedA
   { dup currentcolorspace eq { pop } { setcolorspace } ifelse setcolor } bdef
  /CIEBasedABC /CIEBasedA load def
  /CIEBasedDEF /CIEBasedA load def
  /CIEBasedDEFG /CIEBasedA load def
  /Indexed /setcolorspace where
   { pop /CIEBasedA load }
   { /setindexedcolor cvx }
  ifelse def
end def
/setindexedcolor		% <index> [/Indexed base hival proc|str]
				%   setindexedcolor - (only used for Level 1)
 { mark 3 -1 roll
   2 index 3 get	% Stack: cspace -mark- index proc|str
   dup type /stringtype eq
    { //CIdict 4 index 1 get 0 get get		% # of components
      dup 4 -1 roll mul exch getinterval { 255 div } forall
    }
    { exec
    }
   ifelse
   counttomark 2 add -2 roll pop
   1 get setgcolor
 } bdef
/setgcolor	% (null | <color...>) <colorspace> setgcolor -
 { 1 index null eq
    { pop pop }
    { dup 0 get //Cdict exch get exec }
   ifelse
 } bdef
/fsexec		% <fillop|strokeop> fsexec -
 {		% Preserve the current point, if any.
    { currentpoint } stopped
    { $error /newerror false put   cvx exec }
    { 3 -1 roll cvx exec moveto }
   ifelse
 } bdef

% ---------------- Transformations ---------------- %

/cmmatrix matrix def
/cm { //cmmatrix astore concat } 6 !

% ---------------- Path creation ---------------- %

/m /moveto 2 ~
/l /lineto 2 ~
/c /curveto 6 ~
/h /closepath 0 ~
/v { currentpoint 6 2 roll curveto } 4 !
/y { 2 copy curveto } 4 !
/re
 { 4 2 roll moveto  exch dup 0 rlineto  0 3 -1 roll rlineto  neg 0 rlineto
   closepath
 } 4 !

% ---------------- Path painting and clipping ---------------- %

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -