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

📄 psoutputdev.cc

📁 这是一个做pdf阅读器的源代码文件,是大家学习阅读器资料的很好参考
💻 CC
📖 第 1 页 / 共 5 页
字号:
//========================================================================//// PSOutputDev.cc//// Copyright 1996-2003 Glyph & Cog, LLC////========================================================================#include <aconf.h>#ifdef USE_GCC_PRAGMAS#pragma implementation#endif#include <stdio.h>#include <stddef.h>#include <stdarg.h>#include <signal.h>#include <math.h>#include "GString.h"#include "GList.h"#include "config.h"#include "GlobalParams.h"#include "Object.h"#include "Error.h"#include "Function.h"#include "Gfx.h"#include "GfxState.h"#include "GfxFont.h"#include "UnicodeMap.h"#include "FoFiType1C.h"#include "FoFiTrueType.h"#include "Catalog.h"#include "Page.h"#include "Stream.h"#include "Annot.h"#include "XRef.h"#include "PreScanOutputDev.h"#if HAVE_SPLASH#  include "Splash.h"#  include "SplashBitmap.h"#  include "SplashOutputDev.h"#endif#include "PSOutputDev.h"#ifdef MACOS// needed for setting type/creator of MacOS files#include "ICSupport.h"#endif// the MSVC math.h doesn't define this#ifndef M_PI#define M_PI 3.14159265358979323846#endif//------------------------------------------------------------------------// Resolution at which pages with transparency will be rasterized.#define splashDPI 300//------------------------------------------------------------------------// PostScript prolog and setup//------------------------------------------------------------------------// The '~' escapes mark prolog code that is emitted only in certain// levels:////   ~[123][sn]//      ^   ^----- s=psLevel*Sep, n=psLevel*//      +----- 1=psLevel1*, 2=psLevel2*, 3=psLevel3*static char *prolog[] = {  "/xpdf 75 dict def xpdf begin",  "% PDF special state",  "/pdfDictSize 15 def",  "~1sn",  "/pdfStates 64 array def",  "  0 1 63 {",  "    pdfStates exch pdfDictSize dict",  "    dup /pdfStateIdx 3 index put",  "    put",  "  } for",  "~123sn",  "/pdfSetup {",  "  3 1 roll 2 array astore",  "  /setpagedevice where {",  "    pop 3 dict begin",  "      /PageSize exch def",  "      /ImagingBBox null def",  "      /Policies 1 dict dup begin /PageSize 3 def end def",  "      { /Duplex true def } if",  "    currentdict end setpagedevice",  "  } {",  "    pop pop",  "  } ifelse",  "} def",  "~1sn",  "/pdfOpNames [",  "  /pdfFill /pdfStroke /pdfLastFill /pdfLastStroke",  "  /pdfTextMat /pdfFontSize /pdfCharSpacing /pdfTextRender",  "  /pdfTextRise /pdfWordSpacing /pdfHorizScaling /pdfTextClipPath",  "] def",  "~123sn",  "/pdfStartPage {",  "~1sn",  "  pdfStates 0 get begin",  "~23sn",  "  pdfDictSize dict begin",  "~23n",  "  /pdfFillCS [] def",  "  /pdfFillXform {} def",  "  /pdfStrokeCS [] def",  "  /pdfStrokeXform {} def",  "~1n",  "  /pdfFill 0 def",  "  /pdfStroke 0 def",  "~1s",  "  /pdfFill [0 0 0 1] def",  "  /pdfStroke [0 0 0 1] def",  "~23sn",  "  /pdfFill [0] def",  "  /pdfStroke [0] def",  "  /pdfFillOP false def",  "  /pdfStrokeOP false def",  "~123sn",  "  /pdfLastFill false def",  "  /pdfLastStroke false def",  "  /pdfTextMat [1 0 0 1 0 0] def",  "  /pdfFontSize 0 def",  "  /pdfCharSpacing 0 def",  "  /pdfTextRender 0 def",  "  /pdfTextRise 0 def",  "  /pdfWordSpacing 0 def",  "  /pdfHorizScaling 1 def",  "  /pdfTextClipPath [] def",  "} def",  "/pdfEndPage { end } def",  "~23s",  "% separation convention operators",  "/findcmykcustomcolor where {",  "  pop",  "}{",  "  /findcmykcustomcolor { 5 array astore } def",  "} ifelse",  "/setcustomcolor where {",  "  pop",  "}{",  "  /setcustomcolor {",  "    exch",  "    [ exch /Separation exch dup 4 get exch /DeviceCMYK exch",  "      0 4 getinterval cvx",  "      [ exch /dup load exch { mul exch dup } /forall load",  "        /pop load dup ] cvx",  "    ] setcolorspace setcolor",  "  } def",  "} ifelse",  "/customcolorimage where {",  "  pop",  "}{",  "  /customcolorimage {",  "    gsave",  "    [ exch /Separation exch dup 4 get exch /DeviceCMYK exch",  "      0 4 getinterval",  "      [ exch /dup load exch { mul exch dup } /forall load",  "        /pop load dup ] cvx",  "    ] setcolorspace",  "    10 dict begin",  "      /ImageType 1 def",  "      /DataSource exch def",  "      /ImageMatrix exch def",  "      /BitsPerComponent exch def",  "      /Height exch def",  "      /Width exch def",  "      /Decode [1 0] def",  "    currentdict end",  "    image",  "    grestore",  "  } def",  "} ifelse",  "~123sn",  "% PDF color state",  "~1n",  "/g { dup /pdfFill exch def setgray",  "     /pdfLastFill true def /pdfLastStroke false def } def",  "/G { dup /pdfStroke exch def setgray",  "     /pdfLastStroke true def /pdfLastFill false def } def",  "/fCol {",  "  pdfLastFill not {",  "    pdfFill setgray",  "    /pdfLastFill true def /pdfLastStroke false def",  "  } if",  "} def",  "/sCol {",  "  pdfLastStroke not {",  "    pdfStroke setgray",  "    /pdfLastStroke true def /pdfLastFill false def",  "  } if",  "} def",  "~1s",  "/k { 4 copy 4 array astore /pdfFill exch def setcmykcolor",  "     /pdfLastFill true def /pdfLastStroke false def } def",  "/K { 4 copy 4 array astore /pdfStroke exch def setcmykcolor",  "     /pdfLastStroke true def /pdfLastFill false def } def",  "/fCol {",  "  pdfLastFill not {",  "    pdfFill aload pop setcmykcolor",  "    /pdfLastFill true def /pdfLastStroke false def",  "  } if",  "} def",  "/sCol {",  "  pdfLastStroke not {",  "    pdfStroke aload pop setcmykcolor",  "    /pdfLastStroke true def /pdfLastFill false def",  "  } if",  "} def",  "~23n",  "/cs { /pdfFillXform exch def dup /pdfFillCS exch def",  "      setcolorspace } def",  "/CS { /pdfStrokeXform exch def dup /pdfStrokeCS exch def",  "      setcolorspace } def",  "/sc { pdfLastFill not { pdfFillCS setcolorspace } if",  "      dup /pdfFill exch def aload pop pdfFillXform setcolor",  "     /pdfLastFill true def /pdfLastStroke false def } def",  "/SC { pdfLastStroke not { pdfStrokeCS setcolorspace } if",  "      dup /pdfStroke exch def aload pop pdfStrokeXform setcolor",  "     /pdfLastStroke true def /pdfLastFill false def } def",  "/op { /pdfFillOP exch def",  "      pdfLastFill { pdfFillOP setoverprint } if } def",  "/OP { /pdfStrokeOP exch def",  "      pdfLastStroke { pdfStrokeOP setoverprint } if } def",  "/fCol {",  "  pdfLastFill not {",  "    pdfFillCS setcolorspace",  "    pdfFill aload pop pdfFillXform setcolor",  "    pdfFillOP setoverprint",  "    /pdfLastFill true def /pdfLastStroke false def",  "  } if",  "} def",  "/sCol {",  "  pdfLastStroke not {",  "    pdfStrokeCS setcolorspace",  "    pdfStroke aload pop pdfStrokeXform setcolor",  "    pdfStrokeOP setoverprint",  "    /pdfLastStroke true def /pdfLastFill false def",  "  } if",  "} def",  "~23s",  "/k { 4 copy 4 array astore /pdfFill exch def setcmykcolor",  "     /pdfLastFill true def /pdfLastStroke false def } def",  "/K { 4 copy 4 array astore /pdfStroke exch def setcmykcolor",  "     /pdfLastStroke true def /pdfLastFill false def } def",  "/ck { 6 copy 6 array astore /pdfFill exch def",  "      findcmykcustomcolor exch setcustomcolor",  "      /pdfLastFill true def /pdfLastStroke false def } def",  "/CK { 6 copy 6 array astore /pdfStroke exch def",  "      findcmykcustomcolor exch setcustomcolor",  "      /pdfLastStroke true def /pdfLastFill false def } def",  "/op { /pdfFillOP exch def",  "      pdfLastFill { pdfFillOP setoverprint } if } def",  "/OP { /pdfStrokeOP exch def",  "      pdfLastStroke { pdfStrokeOP setoverprint } if } def",  "/fCol {",  "  pdfLastFill not {",  "    pdfFill aload length 4 eq {",  "      setcmykcolor",  "    }{",  "      findcmykcustomcolor exch setcustomcolor",  "    } ifelse",  "    pdfFillOP setoverprint",  "    /pdfLastFill true def /pdfLastStroke false def",  "  } if",  "} def",  "/sCol {",  "  pdfLastStroke not {",  "    pdfStroke aload length 4 eq {",  "      setcmykcolor",  "    }{",  "      findcmykcustomcolor exch setcustomcolor",  "    } ifelse",  "    pdfStrokeOP setoverprint",  "    /pdfLastStroke true def /pdfLastFill false def",  "  } if",  "} def",  "~123sn",  "% build a font",  "/pdfMakeFont {",  "  4 3 roll findfont",  "  4 2 roll matrix scale makefont",  "  dup length dict begin",  "    { 1 index /FID ne { def } { pop pop } ifelse } forall",  "    /Encoding exch def",  "    currentdict",  "  end",  "  definefont pop",  "} def",  "/pdfMakeFont16 {",  "  exch findfont",  "  dup length dict begin",  "    { 1 index /FID ne { def } { pop pop } ifelse } forall",  "    /WMode exch def",  "    currentdict",  "  end",  "  definefont pop",  "} def",  "~3sn",  "/pdfMakeFont16L3 {",  "  1 index /CIDFont resourcestatus {",  "    pop pop 1 index /CIDFont findresource /CIDFontType known",  "  } {",  "    false",  "  } ifelse",  "  {",  "    0 eq { /Identity-H } { /Identity-V } ifelse",  "    exch 1 array astore composefont pop",  "  } {",  "    pdfMakeFont16",  "  } ifelse",  "} def",  "~123sn",  "% graphics state operators",  "~1sn",  "/q {",  "  gsave",  "  pdfOpNames length 1 sub -1 0 { pdfOpNames exch get load } for",  "  pdfStates pdfStateIdx 1 add get begin",  "  pdfOpNames { exch def } forall",  "} def",  "/Q { end grestore } def",  "~23sn",  "/q { gsave pdfDictSize dict begin } def",  "/Q {",  "  end grestore",  "  /pdfLastFill where {",  "    pop",  "    pdfLastFill {",  "      pdfFillOP setoverprint",  "    } {",  "      pdfStrokeOP setoverprint",  "    } ifelse",  "  } if",  "} def",  "~123sn",  "/cm { concat } def",  "/d { setdash } def",  "/i { setflat } def",  "/j { setlinejoin } def",  "/J { setlinecap } def",  "/M { setmiterlimit } def",  "/w { setlinewidth } def",  "% path segment operators",  "/m { moveto } def",  "/l { lineto } def",  "/c { curveto } def",  "/re { 4 2 roll moveto 1 index 0 rlineto 0 exch rlineto",  "      neg 0 rlineto closepath } def",  "/h { closepath } def",  "% path painting operators",  "/S { sCol stroke } def",  "/Sf { fCol stroke } def",  "/f { fCol fill } def",  "/f* { fCol eofill } def",  "% clipping operators",  "/W { clip newpath } def",  "/W* { eoclip newpath } def",  "/Ws { strokepath clip newpath } def",  "% text state operators",  "/Tc { /pdfCharSpacing exch def } def",  "/Tf { dup /pdfFontSize exch def",  "      dup pdfHorizScaling mul exch matrix scale",  "      pdfTextMat matrix concatmatrix dup 4 0 put dup 5 0 put",  "      exch findfont exch makefont setfont } def",  "/Tr { /pdfTextRender exch def } def",  "/Ts { /pdfTextRise exch def } def",  "/Tw { /pdfWordSpacing exch def } def",  "/Tz { /pdfHorizScaling exch def } def",  "% text positioning operators",  "/Td { pdfTextMat transform moveto } def",  "/Tm { /pdfTextMat exch def } def",  "% text string operators",  "/cshow where {",  "  pop",  "  /cshow2 {",  "    dup {",  "      pop pop",  "      1 string dup 0 3 index put 3 index exec",  "    } exch cshow",  "    pop pop",  "  } def",  "}{",  "  /cshow2 {",  "    currentfont /FontType get 0 eq {",  "      0 2 2 index length 1 sub {",  "        2 copy get exch 1 add 2 index exch get",  "        2 copy exch 256 mul add",  "        2 string dup 0 6 5 roll put dup 1 5 4 roll put",  "        3 index exec",  "      } for",  "    } {",  "      dup {",  "        1 string dup 0 3 index put 3 index exec",  "      } forall",  "    } ifelse",  "    pop pop",  "  } def",  "} ifelse",  "/awcp {", // awidthcharpath  "  exch {",  "    false charpath",  "    5 index 5 index rmoveto",  "    6 index eq { 7 index 7 index rmoveto } if",  "  } exch cshow2",  "  6 {pop} repeat",  "} def",  "/Tj {",  "  fCol",  // because stringwidth has to draw Type 3 chars  "  1 index stringwidth pdfTextMat idtransform pop",  "  sub 1 index length dup 0 ne { div } { pop pop 0 } ifelse",  "  pdfWordSpacing pdfHorizScaling mul 0 pdfTextMat dtransform 32",  "  4 3 roll pdfCharSpacing pdfHorizScaling mul add 0",  "  pdfTextMat dtransform",  "  6 5 roll Tj1",  "} def",  "/Tj16 {",  "  fCol",  // because stringwidth has to draw Type 3 chars  "  2 index stringwidth pdfTextMat idtransform pop",  "  sub exch div",  "  pdfWordSpacing pdfHorizScaling mul 0 pdfTextMat dtransform 32",  "  4 3 roll pdfCharSpacing pdfHorizScaling mul add 0",  "  pdfTextMat dtransform",  "  6 5 roll Tj1",  "} def",  "/Tj16V {",  "  fCol",  // because stringwidth has to draw Type 3 chars  "  2 index stringwidth pdfTextMat idtransform exch pop",  "  sub exch div",  "  0 pdfWordSpacing pdfTextMat dtransform 32",  "  4 3 roll pdfCharSpacing add 0 exch",  "  pdfTextMat dtransform",  "  6 5 roll Tj1",  "} def",  "/Tj1 {",  "  0 pdfTextRise pdfTextMat dtransform rmoveto",  "  currentpoint 8 2 roll",  "  pdfTextRender 1 and 0 eq {",  "    6 copy awidthshow",  "  } if",  "  pdfTextRender 3 and dup 1 eq exch 2 eq or {",  "    7 index 7 index moveto",  "    6 copy",  "    currentfont /FontType get 3 eq { fCol } { sCol } ifelse",  "    false awcp currentpoint stroke moveto",  "  } if",  "  pdfTextRender 4 and 0 ne {",  "    8 6 roll moveto",  "    false awcp",  "    /pdfTextClipPath [ pdfTextClipPath aload pop",  "      {/moveto cvx}",  "      {/lineto cvx}",  "      {/curveto cvx}",  "      {/closepath cvx}",  "    pathforall ] def",  "    currentpoint newpath moveto",  "  } {",  "    8 {pop} repeat",  "  } ifelse",  "  0 pdfTextRise neg pdfTextMat dtransform rmoveto",  "} def",  "/TJm { pdfFontSize 0.001 mul mul neg 0",  "       pdfTextMat dtransform rmoveto } def",  "/TJmV { pdfFontSize 0.001 mul mul neg 0 exch",  "        pdfTextMat dtransform rmoveto } def",  "/Tclip { pdfTextClipPath cvx exec clip newpath",  "         /pdfTextClipPath [] def } def",  "~1ns",  "% Level 1 image operators",  "~1n",

⌨️ 快捷键说明

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