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

📄 pdf_draw.ps

📁 GhostScript的源代码
💻 PS
📖 第 1 页 / 共 2 页
字号:
		% Stack: filepos /Indexed basespace hival lookupstream
	1 index 1 add
		% Stack: filepos /Indexed basespace hival lookupstream len
	3 index
	  dup dup type /arraytype eq { 0 get } if
	  //csncompdict exch get exec mul
	string readstring pop
		% Stack: filepos /Indexed basespace hival table
	5 -1 roll PDFfile exch setfileposition
    }
    ifelse 4 array astore
  }
  /Pattern
   { dup type /nametype ne
      { dup length 1 ge
	 { 1 get resolvecolorspace
	   /Pattern exch 2 array astore
	 }
	if
      }
     if
   }
.dicttomark readonly def

/cssubst {		% <csname> cssubst <cspace'> true
			% <csname> cssubst false
  dup resolvecolorspace
  dup 1 index ne { exch pop true } { pop pop false } ifelse
} bdef

/csresolve		% <csresourcename> csresolve <cspace>
 { dup Page /ColorSpace rget
    { exch pop resolvecolorspace }
    { /undefined cvx signalerror }
   ifelse
 } bdef
/resolvecolorspace {	% <cspace> resolvecolorspace <cspace'>
  dup dup type /arraytype eq { 0 get } if
  //csrdict exch .knownget {
    exec dup type /nametype ne { dup length 1 eq { 0 get } if } if
  } {
    csresolve
  } ifelse
} bdef

/scresolve	% <c0> ... scresolve <multi>
 {		% We can't really make sc[n] and SC[N] work, because
		% the color space information isn't available at
		% conversion time; so we hack it by assuming that
		% all the operands on the stack are used, and that
		% if the top operand is a name, it's a Pattern resource.
   dup type /nametype eq
    { Page /Pattern rget { resolvepattern } { null } ifelse }
   if
   count 1 gt
 } bdef
/resolvepattern		% <patternstreamdict> resolvepattern <patterndict>
 {		% Don't do the resolvestream now: just capture the data
		% from the file if necessary.
   dup length dict copy
   dup /FilePosition .knownget
    { 1 index /File get dup fileposition 3 1 roll
		% Stack: dict savepos pos file
      dup 3 -1 roll setfileposition
      dup 3 index /Length get string readstring pop
		% Stack: dict savepos file string
      3 1 roll exch setfileposition
      1 index /File 3 -1 roll put
      dup /FilePosition undef
    }
   if
   dup /PaintProc {
     DEBUG { (%Begin PaintProc) = flush } if
     false resolvestream pdfopdict .pdfrun
     DEBUG { (%End PaintProc) = flush } if
   } put
   DEBUG {
     (%Pattern: ) print dup === flush
   } if
 } bdef

drawopdict begin
  /g { /DeviceGray cssubst { cs sc1 } { g } ifelse } bdef
  /rg { /DeviceRGB cssubst { cs sc* } { rg } ifelse } bdef
  /k { k } bdef
  /cs { csresolve cs } bdef
  /sc { scresolve { sc* } { sc1 } ifelse } bdef
  /scn /sc load def
  /G { /DeviceGray cssubst { CS SC1 } { G } ifelse } bdef
  /RG { /DeviceRGB cssubst { CS SC* } { RG } ifelse } bdef
  /K { K } bdef
  /CS { csresolve CS } bdef
  /SC { scresolve { SC* } { SC1 } ifelse } bdef
  /SCN /SC load def
end

% ---------------- Paths ---------------- %

drawopdict begin
			% Path construction
  /m /moveto load def
  /l /lineto load def
  /c /curveto load def
  /v { currentpoint 6 2 roll curveto } def
  /y { 2 copy curveto } def
  /re {
   4 2 roll moveto  exch dup 0 rlineto  0 3 -1 roll rlineto  neg 0 rlineto
   closepath
  } def
  /h /closepath load def
			% Path painting and clipping
  /n { n } def
  /S { S } def
  /s { s } def
  /f { f } def
  /f* { f* } def
  /B { B } def
  /b { b } def
  /B* { B* } def
  /b* { b* } def
  /W { W } def
  /W* { W* } def
end

% ---------------- XObjects ---------------- %

/xobjectprocs mark		% <dict> -proc- -
  /Image { DoImage }
  /Form { DoForm }
  /PS { DoPS }
.dicttomark readonly def

% Note that the keys in defaultdecodedict are resolved (PostScript, not PDF)
% color space names.
/01_1 [0 1] readonly def
/01_3 [0 1 0 1 0 1] readonly def
/01_4 [0 1 0 1 0 1 0 1] readonly def
/defaultdecodedict mark
  /DeviceGray { pop //01_1 }
  /DeviceRGB { pop //01_3 }
  /DeviceCMYK { pop //01_4 }
  /CIEBasedA { 1 get /RangeA .knownget not { //01_1 } if }
  /CIEBasedABC { 1 get /RangeABC .knownget not { //01_3 } if }
  /Separation { pop //01_1 }
  /DeviceN {
    dup 1 oget length [ exch {0 1} repeat ] readonly
  }
.dicttomark readonly def

/makeimagedict
 { dup length dict
   1 index /ColorSpace knownoget
    { resolvecolorspace
      dup type /arraytype eq { dup length 1 eq { 0 get } if } if
      exch begin /ColorSpace exch def
    }
    { begin
    }
   ifelse
   /ImageType 1 def
		% Always define ImageMask appropriately.
   dup /ImageMask knownoget dup { and } if
     /ImageMask exch def
   /Width 2 copy oget def
   /Height 2 copy oget def
   /BitsPerComponent 2 copy oget def
   /Decode 2 copy knownoget not
    {		% Decode is required for the PostScript image operators.
      ImageMask
       { [0 1]
       }
       { ColorSpace dup type /arraytype eq { 0 get } if dup /Indexed eq
	  { pop [ 0 1 BitsPerComponent bitshift 1 sub ] }
	  { defaultdecodedict exch get ColorSpace exch exec }
	 ifelse
       }
      ifelse
    }
   if def
   /Interpolate 2 copy knownoget { def } { pop } ifelse
   /ImageMatrix Width 0 0 Height neg 0 Height 6 array astore def
		% Even though we're going to read data,
		% pass false to resolvestream so that
		% it doesn't try to use Length (which may not be present).
   false resolvestream
     /DataSource exch def
  currentdict end
} bdef

/DoImage {
  makeimagedict
  dup /Mask knownoget {
    dup type /arraytype eq {
      1 index /ImageType 4 put
      1 index /MaskColor 3 -1 roll put
    } {
		% Mask is a stream, another Image XObject.
      makeimagedict
      4 dict begin
      /ImageType 3 def
      /InterleaveType 3 def
      /MaskDict exch def
      /DataDict exch def
      currentdict end
    } ifelse
  } if
  dup /ImageMask get
   { setfillcolor imagemask }
   { dup /ColorSpace get csset setcolorspace pop image }
  ifelse
} bdef

/DoForm {
  dup length dict copy
  dup [ /pop load 2 index /Resources knownoget { oforce } { 0 dict } ifelse
  3 index false /resolvestream cvx
  pdfopdict /.pdfruncontext cvx
  ] cvx /PaintProc exch put
  execform
} bdef

/DoPS {
  true resolvestream cvx exec
} bdef

drawopdict begin
  /Do
    { PDFfile fileposition exch
      dup Page /XObject rget not { /undefined cvx signalerror } if
      exch pop dup /Subtype get xobjectprocs exch get exec
      PDFfile exch setfileposition
    } bdef
end

% ---------------- In-line images ---------------- %

% Undo the abbreviations in an in-line image dictionary.
% Note that these can appear as keys, values, or members of array values.
% /I is ambiguous; we check specially for it below.
/unabbrevdict mark
	% Top-level dictionary keys
  /BPC /BitsPerComponent  /CS /ColorSpace  /D /Decode  /DP /DecodeParms
  /F /Filter  /H /Height  /IM /ImageMask  /W /Width
	% Values
  /AHx /ASCIIHexDecode  /A85 /ASCII85Decode  /CC /CalCMYK
  /CCF /CCITTFaxDecode  /CG /CalGray  /CR /CalRGB
  /DCT /DCTDecode  /CMYK /DeviceCMYK  /Fl /FlateDecode
  /G /DeviceGray  /RGB /DeviceRGB
  /I /Indexed  /LZW /LZWDecode  /RL /RunLengthDecode
.dicttomark readonly def
/unabbrev		% <obj> unabbrev <obj'>
 { dup type /nametype eq
    { unabbrevdict 1 index .knownget { exch pop } if
    }
    { dup type /arraytype eq
       { dup 0 1 2 index length 1 sub
	  { 2 copy get unabbrev put dup
	  }
	 for pop
       }
      if
    }
   ifelse
 } bdef

drawopdict begin
  /BI { mark } bdef
  /ID
    { counttomark
       { counttomark 1 roll
	 dup /I eq { pop /Interpolate } { unabbrev } ifelse
       }
      repeat
      /File PDFsource
      .dicttomark DoImage
      PDFsource token pop /EI ne { /ID cvx /syntaxerror signalerror } if
    } bdef
end

% ================================ Text ================================ %

drawopdict begin
			% Text control
  /BT { BT } def
  /ET { ET } def
  /Tc { Tc } def
  /TL { TL } def
  /Tr { Tr } def
  /Ts { Ts } def
  /Tw { Tw } def
  /Tz { Tz } def
			% Text positioning
  /Td { Td } def
  /TD { TD } def
  /Tm { Tm } def
  /T* { T* } def
			% Text painting
  /Tj { Tj } def
  /' { ' } def
  /" { " } def
  /TJ { TJ } def
end

end			% pdfdict
end			% GS_PDF_ProcSet
.setglobal

⌨️ 快捷键说明

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