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

📄 psoutputdev.cc

📁 source code: Covert TXT to PDF
💻 CC
📖 第 1 页 / 共 5 页
字号:
//========================================================================//// PSOutputDev.cc//// Copyright 1996-2002 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 "config.h"#include "GlobalParams.h"#include "Object.h"#include "Error.h"#include "Function.h"#include "Gfx.h"#include "GfxState.h"#include "GfxFont.h"#include "CharCodeToUnicode.h"#include "UnicodeMap.h"#include "FontFile.h"#include "Catalog.h"#include "Page.h"#include "Stream.h"#include "Annot.h"#include "PSOutputDev.h"#ifdef MACOS// needed for setting type/creator of MacOS files#include "ICSupport.h"#endif//------------------------------------------------------------------------// PostScript prolog and setup//------------------------------------------------------------------------static char *prolog[] = {  "/xpdf 75 dict def xpdf begin",  "% PDF special state",  "/pdfDictSize 14 def",  "/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",  "/pdfStartPage {",  "  pdfDictSize dict begin",  "  /pdfFill [0] def",  "  /pdfStroke [0] def",  "  /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",  "} def",  "/pdfEndPage { end } def",  "% 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 cvx",  "      [ 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",  "% PDF color state",  "/sCol {",  "  pdfLastStroke not {",  "    pdfStroke aload length",  "    dup 1 eq {",  "      pop setgray",  "    }{",  "      dup 3 eq {",  "        pop setrgbcolor",  "      }{",  "        4 eq {",  "          setcmykcolor",  "        }{",  "          findcmykcustomcolor exch setcustomcolor",  "        } ifelse",  "      } ifelse",  "    } ifelse",  "    /pdfLastStroke true def /pdfLastFill false def",  "  } if",  "} def",  "/fCol {",  "  pdfLastFill not {",  "    pdfFill aload length",  "    dup 1 eq {",  "      pop setgray",  "    }{",  "      dup 3 eq {",  "        pop setrgbcolor",  "      }{",  "        4 eq {",  "          setcmykcolor",  "        }{",  "          findcmykcustomcolor exch setcustomcolor",  "        } ifelse",  "      } ifelse",  "    } ifelse",  "    /pdfLastFill true def /pdfLastStroke false def",  "  } if",  "} def",  "% 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",  "/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",  "% graphics state operators",  "/q { gsave pdfDictSize dict begin } def",  "/Q { end grestore } def",  "/cm { concat } def",  "/d { setdash } def",  "/i { setflat } def",  "/j { setlinejoin } def",  "/J { setlinecap } def",  "/M { setmiterlimit } def",  "/w { setlinewidth } def",  "% color operators",  "/g { dup 1 array astore /pdfFill exch def setgray",  "     /pdfLastFill true def /pdfLastStroke false def } def",  "/G { dup 1 array astore /pdfStroke exch def setgray",  "     /pdfLastStroke true def /pdfLastFill false def } def",  "/rg { 3 copy 3 array astore /pdfFill exch def setrgbcolor",  "      /pdfLastFill true def /pdfLastStroke false def } def",  "/RG { 3 copy 3 array astore /pdfStroke exch def setrgbcolor",  "      /pdfLastStroke true def /pdfLastFill false def } def",  "/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",  "% 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",  "% 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",  "/awcp { % awidthcharpath",  "  exch {",  "    1 string dup 0 3 index put 2 index charpath",  "    3 index 3 index rmoveto",  "    4 index eq { 5 index 5 index rmoveto } if",  "  } forall",  "  6 {pop} repeat",  "} def",  "/Tj { fCol",  // because stringwidth has to draw Type 3 chars  "      0 pdfTextRise pdfTextMat dtransform rmoveto",  "      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",  "      currentpoint 8 2 roll",  "      pdfTextRender 1 and 0 eq {",  "        6 copy awidthshow",  "      } if",  "      pdfTextRender 3 and dup 1 eq exch 2 eq or {",  "        8 6 roll moveto",  "        currentfont /FontType get 3 eq { fCol } { sCol } ifelse",  "        false awcp currentpoint stroke moveto",  "      } {",  "        8 {pop} repeat",  "      } ifelse",  "      0 pdfTextRise neg pdfTextMat dtransform rmoveto } def",  "/Tj16 { pdfTextRender 1 and 0 eq { fCol } { sCol } ifelse",  "        0 pdfTextRise pdfTextMat dtransform rmoveto",  "        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 awidthshow",  "        0 pdfTextRise neg pdfTextMat dtransform rmoveto } def",  "/Tj16V { pdfTextRender 1 and 0 eq { fCol } { sCol } ifelse",  "         0 pdfTextRise pdfTextMat dtransform rmoveto",  "         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 awidthshow",  "         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",  "% Level 1 image operators",  "/pdfIm1 {",  "  /pdfImBuf1 4 index string def",  "  { currentfile pdfImBuf1 readhexstring pop } image",  "} def",  "/pdfIm1Sep {",  "  /pdfImBuf1 4 index string def",  "  /pdfImBuf2 4 index string def",  "  /pdfImBuf3 4 index string def",  "  /pdfImBuf4 4 index string def",  "  { currentfile pdfImBuf1 readhexstring pop }",  "  { currentfile pdfImBuf2 readhexstring pop }",  "  { currentfile pdfImBuf3 readhexstring pop }",  "  { currentfile pdfImBuf4 readhexstring pop }",  "  true 4 colorimage",  "} def",  "/pdfImM1 {",  "  /pdfImBuf1 4 index 7 add 8 idiv string def",  "  { currentfile pdfImBuf1 readhexstring pop } imagemask",  "} def",  "% Level 2 image operators",  "/pdfImBuf 100 string def",  "/pdfIm {",  "  image",  "  { currentfile pdfImBuf readline",  "    not { pop exit } if",  "    (%-EOD-) eq { exit } if } loop",  "} def",  "/pdfImSep {",  "  findcmykcustomcolor exch",  "  dup /Width get /pdfImBuf1 exch string def",  "  begin Width Height BitsPerComponent ImageMatrix DataSource end",  "  /pdfImData exch def",  "  { pdfImData pdfImBuf1 readstring pop",  "    0 1 2 index length 1 sub {",  "      1 index exch 2 copy get 255 exch sub put",  "    } for }",  "  6 5 roll customcolorimage",  "  { currentfile pdfImBuf readline",  "    not { pop exit } if",  "    (%-EOD-) eq { exit } if } loop",  "} def",  "/pdfImM {",  "  fCol imagemask",  "  { currentfile pdfImBuf readline",  "    not { pop exit } if",  "    (%-EOD-) eq { exit } if } loop",  "} def",  "end",  NULL};static char *cmapProlog[] = {  "/CIDInit /ProcSet findresource begin",  "10 dict begin",  "  begincmap",  "  /CMapType 1 def",  "  /CMapName /Identity-H def",  "  /CIDSystemInfo 3 dict dup begin",  "    /Registry (Adobe) def",  "    /Ordering (Identity) def",  "    /Supplement 0 def",  "  end def",  "  1 begincodespacerange",  "    <0000> <ffff>",  "  endcodespacerange",  "  0 usefont",  "  1 begincidrange",  "    <0000> <ffff> 0",  "  endcidrange",  "  endcmap",  "  currentdict CMapName exch /CMap defineresource pop",  "end",  "10 dict begin",  "  begincmap",  "  /CMapType 1 def",  "  /CMapName /Identity-V def",  "  /CIDSystemInfo 3 dict dup begin",  "    /Registry (Adobe) def",  "    /Ordering (Identity) def",  "    /Supplement 0 def",  "  end def",  "  /WMode 1 def",  "  1 begincodespacerange",  "    <0000> <ffff>",  "  endcodespacerange",  "  0 usefont",  "  1 begincidrange",  "    <0000> <ffff> 0",  "  endcidrange",  "  endcmap",  "  currentdict CMapName exch /CMap defineresource pop",  "end",  "end",  NULL};//------------------------------------------------------------------------// Fonts//------------------------------------------------------------------------struct PSSubstFont {  char *psName;			// PostScript name  double mWidth;		// width of 'm' character};static char *psFonts[] = {  "Courier",  "Courier-Bold",  "Courier-Oblique",  "Courier-BoldOblique",  "Helvetica",  "Helvetica-Bold",  "Helvetica-Oblique",  "Helvetica-BoldOblique",  "Symbol",  "Times-Roman",  "Times-Bold",  "Times-Italic",  "Times-BoldItalic",  "ZapfDingbats",  NULL};static PSSubstFont psSubstFonts[] = {  {"Helvetica",             0.833},  {"Helvetica-Oblique",     0.833},  {"Helvetica-Bold",        0.889},  {"Helvetica-BoldOblique", 0.889},  {"Times-Roman",           0.788},  {"Times-Italic",          0.722},  {"Times-Bold",            0.833},  {"Times-BoldItalic",      0.778},  {"Courier",               0.600},  {"Courier-Oblique",       0.600},  {"Courier-Bold",          0.600},  {"Courier-BoldOblique",   0.600}};// Encoding info for substitute 16-bit fontstruct PSFont16Enc {  Ref fontID;  GString *enc;};//------------------------------------------------------------------------// process colors//------------------------------------------------------------------------#define psProcessCyan     1#define psProcessMagenta  2#define psProcessYellow   4#define psProcessBlack    8#define psProcessCMYK    15//------------------------------------------------------------------------// PSOutCustomColor//------------------------------------------------------------------------class PSOutCustomColor {public:  PSOutCustomColor(double cA, double mA,		   double yA, double kA, GString *nameA);  ~PSOutCustomColor();  double c, m, y, k;  GString *name;  PSOutCustomColor *next;};PSOutCustomColor::PSOutCustomColor(double cA, double mA,				   double yA, double kA, GString *nameA) {  c = cA;  m = mA;  y = yA;  k = kA;  name = nameA;  next = NULL;}PSOutCustomColor::~PSOutCustomColor() {  delete name;}//------------------------------------------------------------------------// PSOutputDev//------------------------------------------------------------------------

⌨️ 快捷键说明

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