Language.htm 69 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  2. "http://www.w3.org/TR/html4/loose.dtd">
  3. <html>
  4. <head>
  5. <title>Ghostscript and the PostScript language</title>
  6. <!-- $Id: Language.htm,v 1.34.2.4 2002/02/01 05:31:25 raph Exp $ -->
  7. <!-- Originally: language.txt -->
  8. <link rel="stylesheet" type="text/css" href="gs.css" title="Ghostscript Style">
  9. </head>
  10. <body>
  11. <!-- [1.0 begin visible header] ============================================ -->
  12. <!-- [1.1 begin headline] ================================================== -->
  13. <h1>Ghostscript and the PostScript language</h1>
  14. <!-- [1.1 end headline] ==================================================== -->
  15. <!-- [1.2 begin table of contents] ========================================= -->
  16. <h2>Table of contents</h2>
  17. <blockquote><ul>
  18. <li><a href="#Capabilities">Ghostscript's capabilities in relation to PostScript</a>
  19. <li><a href="#Implementation_limits">Implementation limits</a>
  20. <ul>
  21. <li><a href="#Architectural_limits">Architectural limits</a>
  22. <li><a href="#Typical_memory_limits">Typical memory limits in LanguageLevel 1</a>
  23. <li><a href="#VM_consumption">Other differences in VM consumption</a>
  24. </ul>
  25. <li><a href="#Additional_operators">Additional operators in Ghostscript</a>
  26. <ul>
  27. <li><a href="#Graphics_and_text">Graphics and text operators</a>
  28. <ul>
  29. <li><a href="#Transparency">Transparency</a>
  30. <ul>
  31. <li><a href="#Transparency_graphics_state_operators">Graphics state operators</a>
  32. <li><a href="#Transparency_rendering_stack_operators">Rendering stack operators</a>
  33. <li><a href="#Transparency_ImageType">New ImageType</a>
  34. </ul>
  35. <li><a href="#Graphics_state">Other graphics state operators</a>
  36. <li><a href="#Path">Path operators</a>
  37. <li><a href="#Painting">Painting operators</a>
  38. <li><a href="#Character">Character operators</a>
  39. </ul>
  40. <li><a href="#Other">Other operators</a>
  41. <ul>
  42. <li><a href="#Mathematical">Mathematical operators</a>
  43. <li><a href="#Dictionary">Dictionary operators</a>
  44. <li><a href="#String">String and name operators</a>
  45. <li><a href="#Relational">Relational operators</a>
  46. <li><a href="#File">File operators</a>
  47. <li><a href="#Virtual_memory">Virtual memory operators</a>
  48. <li><a href="#Miscellaneous">Miscellaneous operators</a>
  49. <li><a href="#Device">Device operators</a>
  50. </ul>
  51. </ul>
  52. <li><a href="#Filters">Filters</a>
  53. <ul>
  54. <li><a href="#Standard_filters">Standard filters</a>
  55. <li><a href="#Non_standard_filters">Non-standard filters</a>
  56. <li><a href="#Unstable_filters">Unstable filters</a>
  57. </ul>
  58. <li><a href="#Device_parameters">Device parameters</a>
  59. <li><a href="#User_parameters">User parameters</a>
  60. <li><a href="#Miscellaneous_additions">Miscellaneous additions</a>
  61. </ul></blockquote>
  62. <!-- [1.2 end table of contents] =========================================== -->
  63. <!-- [1.3 begin hint] ====================================================== -->
  64. <p>For other information, see the <a href="Readme.htm">Ghostscript
  65. overview</a>.
  66. <!-- [1.3 end hint] ======================================================== -->
  67. <hr>
  68. <!-- [1.0 end visible header] ============================================== -->
  69. <!-- [2.0 begin contents] ================================================== -->
  70. <h2><a name="Capabilities"></a>Ghostscript's capabilities in relation to PostScript</h2>
  71. <p>
  72. The Ghostscript interpreter, except as noted below, is intended to execute
  73. properly any source program written in the (LanguageLevel 3)
  74. <b>PostScript</b> language as defined in the <cite>PostScript
  75. Language Reference, Third Edition</cite> (ISBN 0-201-37922-8) published by
  76. Addison-Wesley in mid-1999. However, the interpreter is configurable in
  77. ways that can restrict it to various subsets of this language.
  78. Specifically, the base interpreter accepts the Level 1 subset of the
  79. PostScript language, as defined in the first edition of the <cite>PostScript
  80. Language Reference Manual</cite> (ISBN 0-201-10174-2) Addison-Wesley 1985,
  81. plus the file system, version 25.0 language, and miscellaneous additions
  82. listed in sections A.1.6, A.1.7, and A.1.8 of the Second Edition
  83. respectively, including allowing a string operand for the
  84. "<b><tt>status</tt></b>" operator. The base interpreter may be configured
  85. (see the <a href="Make.htm">documentation on building Ghostscript</a> for
  86. how to configure it) by adding any combination of the following:
  87. <ul>
  88. <li>The ability to process PostScript Type 1 fonts. This facility is
  89. normally included in the interpreter.
  90. <li>The CMYK color extensions listed in section A.1.4 of the Second Edition
  91. (including <b><tt>colorimage</tt></b>). These facilities are available
  92. only if the <b><tt>color</tt></b>, <b><tt>dps</tt></b>, or
  93. <b><tt>level2</tt></b> feature was selected when Ghostscript was built.
  94. <li>The Display PostScript extensions listed in section A.1.3 of the Second
  95. Edition, but excluding the operators listed in section A.1.2. These
  96. facilities are available only if the <b><tt>dps</tt></b> feature or the
  97. <b><tt>level2</tt></b> feature was selected when Ghostscript was built.
  98. <li>The composite font extensions listed in section A.1.5 of the Second
  99. Edition, and the ability to handle Type 0 fonts. These facilities are
  100. available only if the <b><tt>compfont</tt></b> feature or the
  101. <b><tt>level2</tt></b> feature was selected when Ghostscript was built.
  102. <li>The ability to load TrueType fonts and to handle PostScript Type 42
  103. (encapsulated TrueType) fonts. These facilities are available only if the
  104. <b><tt>ttfont</tt></b> feature was selected when Ghostscript was built.
  105. <li>The PostScript Level 2 "filter" facilities except the
  106. <b><tt>DCTEncode</tt></b> and <b><tt>DCTDecode</tt></b> filters. These
  107. facilities are available only if the <b><tt>filter</tt></b>,
  108. <b><tt>dps</tt></b>, or <b><tt>level2</tt></b> feature was selected when
  109. Ghostscript was built.
  110. <li>The PostScript Level 2 <b><tt>DCTEncode</tt></b> and
  111. <b><tt>DCTDecode</tt></b> filters. These facilities are available only if
  112. the <b><tt>dct</tt></b> or <b><tt>level2</tt></b> feature was selected when
  113. Ghostscript was built.
  114. <li>All the other PostScript Level 2 operators and facilities listed in
  115. section A.1.1 of the Second Edition and not listed in any of the other
  116. A.1.n sections. These facilities are available only if the
  117. <b><tt>level2</tt></b> feature was selected when Ghostscript was built.
  118. <li>All PostScript LanguageLevel 3 operators and facilities listed in the
  119. Third Edition, except as noted below. These facilities are available only
  120. if the <b><tt>psl3</tt></b> feature was selected when Ghostscript was built.
  121. <li>The ability to recognize DOS EPSF files and process only the PostScript
  122. part, ignoring bitmap previews or other information. This facility is
  123. available only if the <b><tt>epsf</tt></b> feature was selected when
  124. Ghostscript was built.
  125. </ul>
  126. <p>
  127. Ghostscript currently does not implement the following PostScript
  128. LanguageLevel 3 facilities:
  129. <ul>
  130. <li>Native <b><tt>Separation</tt></b> and <b><tt>DeviceN</tt></b> color
  131. spaces -- the alternate space is always used.
  132. <li>Settable <b><tt>ProcessColorModel</tt></b> for page devices, except for
  133. a very few special devices.
  134. <li><b><tt>IODevice</tt></b>s other than <b><tt>%stdin</tt></b>,
  135. <b><tt>%stdout</tt></b>, <b><tt>%stderr</tt></b>, <b><tt>%lineedit</tt></b>,
  136. <b><tt>%statementedit</tt></b>, <b><tt>%os%</tt></b>, and (if configured)
  137. <b><tt>%pipe%</tt></b>.
  138. </ul>
  139. <p>
  140. Ghostscript can also interpret files in the Portable Document Format (PDF)
  141. 1.3 format defined in the <a
  142. href="http://partners.adobe.com/asn/developer/PDFS/TN/PLRM.pdf"><em>Portable
  143. Document Format Reference Manual</em> Version 1.3</a> of March 11, 1999,
  144. distributed by <a href="http://www.adobe.com/">Adobe Systems
  145. Incorporated</a>, except as noted below. This facility is available only if
  146. the <b><tt>pdf</tt></b> feature was selected when Ghostscript was built.
  147. <p>
  148. Ghostscript currently does not implement the following PDF 1.3 facilities:
  149. <ul>
  150. <li>Native <b><tt>Separation</tt></b> and <b><tt>DeviceN</tt></b> color
  151. spaces, as noted above for PostScript.
  152. <li>Native <b><tt>ICCBased</tt></b> color spaces -- these too always use the
  153. alternate space.
  154. </ul>
  155. <p>
  156. Ghostscript also includes a number of
  157. <a href="#Additional_operators">additional operators</a> defined below that
  158. are not in the PostScript language defined by Adobe.
  159. <hr>
  160. <h2><a name="Implementation_limits"></a>Implementation limits</h2>
  161. <p>
  162. The implementation limits show here correspond to those in Tables B.1 and
  163. B.2 of the Second and Third Editions, which describe the quantities fully.
  164. Where Ghostscript's limits are different from those of Adobe's
  165. implementations (as shown in the Third Edition), Adobe's limits are also
  166. shown.
  167. <h3><a name="Architectural_limits"></a>Architectural limits</h3>
  168. <blockquote><table cellpadding=0 cellspacing=0>
  169. <tr><th colspan=7 bgcolor="#CCCC00"><hr><font size="+1">Architectural limits (corresponds to Adobe table B.1)</font><hr>
  170. <tr valign=bottom>
  171. <th align=left>Quantity
  172. <td>&nbsp;&nbsp;
  173. <th align=left>Limit
  174. <td>&nbsp;&nbsp;
  175. <th align=left>Type
  176. <td>&nbsp;&nbsp;
  177. <th align=left>Adobe
  178. <tr> <td colspan=7><hr>
  179. <tr valign=top> <td>integer
  180. <td>&nbsp;
  181. <td>32-bit
  182. <td>&nbsp;
  183. <td>twos complement integer
  184. <td>&nbsp;
  185. <td>&nbsp;
  186. <tr valign=top> <td>real
  187. <td>&nbsp;
  188. <td>single-precision
  189. <td>&nbsp;
  190. <td>IEEE float
  191. <td>&nbsp;
  192. <td>&nbsp;
  193. <tr valign=top> <td>array
  194. <td>&nbsp;
  195. <td>65535
  196. <td>&nbsp;
  197. <td>elements
  198. <td>&nbsp;
  199. <td>&nbsp;
  200. <tr valign=top> <td>dictionary
  201. <td>&nbsp;
  202. <td>65534
  203. <td>&nbsp;
  204. <td>elements
  205. <td>&nbsp;
  206. <td>65535
  207. <tr valign=top> <td>string
  208. <td>&nbsp;
  209. <td>65535
  210. <td>&nbsp;
  211. <td>characters
  212. <td>&nbsp;
  213. <td>&nbsp;
  214. <tr valign=top> <td>name
  215. <td>&nbsp;
  216. <td>16383
  217. <td>&nbsp;
  218. <td>characters
  219. <td>&nbsp;
  220. <td>127
  221. <tr valign=top> <td>filename
  222. <td>&nbsp;
  223. <td>128*
  224. <td>&nbsp;
  225. <td>characters
  226. <td>&nbsp;
  227. <td>&nbsp;
  228. <tr valign=top> <td><b><tt>save</tt></b> level
  229. <td>&nbsp;
  230. <td>none
  231. <td>&nbsp;
  232. <td>(capacity of memory)
  233. <td>&nbsp;
  234. <td>15
  235. <tr valign=top> <td><b><tt>gsave</tt></b> level
  236. <td>&nbsp;
  237. <td>none
  238. <td>&nbsp;
  239. <td>(capacity of memory)
  240. <td>&nbsp;
  241. <td>13
  242. </table></blockquote>
  243. <p>
  244. * The limit on the length of a file name is 128 characters if the name
  245. starts with a %...% IODevice designation, or 124 characters if it does not.
  246. <h3><a name="Typical_memory_limits"></a>Typical memory limits in LanguageLevel 1</h3>
  247. <blockquote><table cellpadding=0 cellspacing=0>
  248. <tr><th colspan=7 bgcolor="#CCCC00"><hr><font size="+1">Memory limits (corresponds to Adobe table B.2)</font><hr>
  249. <tr valign=bottom>
  250. <th align=left>Quantity
  251. <td>&nbsp;&nbsp;
  252. <th align=left>Limit
  253. <td>&nbsp;&nbsp;
  254. <th align=left>Type
  255. <td>&nbsp;&nbsp;
  256. <th align=left>Adobe
  257. <tr> <td colspan=7><hr>
  258. <tr valign=top> <td><b><tt>userdict</tt></b>
  259. <td>&nbsp;
  260. <td>200
  261. <td>&nbsp;
  262. <td>&nbsp;
  263. <td>&nbsp;
  264. <td>&nbsp;
  265. <tr valign=top> <td><b><tt>FontDirectory</tt></b>
  266. <td>&nbsp;
  267. <td>100
  268. <td>&nbsp;
  269. <td>&nbsp;
  270. <td>&nbsp;
  271. <td>&nbsp;
  272. <tr valign=top> <td>operand stack
  273. <td>&nbsp;
  274. <td>800
  275. <td>&nbsp;
  276. <td>&nbsp;
  277. <td>&nbsp;
  278. <td>500
  279. <tr valign=top> <td>dictionary stack
  280. <td>&nbsp;
  281. <td>20
  282. <td>&nbsp;
  283. <td>&nbsp;
  284. <tr valign=top> <td>execution stack
  285. <td>&nbsp;
  286. <td>250
  287. <td>&nbsp;
  288. <td>&nbsp;
  289. <tr valign=top> <td>interpreter level
  290. <td>&nbsp;
  291. <td>none
  292. <td>&nbsp;
  293. <td>(capacity of memory)
  294. <td>&nbsp;
  295. <td>10
  296. <tr valign=top> <td>path
  297. <td>&nbsp;
  298. <td>none
  299. <td>&nbsp;
  300. <td>(capacity of memory)
  301. <td>&nbsp;
  302. <td>1500
  303. <tr valign=top> <td>dash
  304. <td>&nbsp;
  305. <td>11
  306. <td>&nbsp;
  307. <td>&nbsp;
  308. <tr valign=top> <td>VM
  309. <td>&nbsp;
  310. <td>none
  311. <td>&nbsp;
  312. <td>(capacity of memory)
  313. <td>&nbsp;
  314. <td>240000
  315. <tr valign=top> <td>file
  316. <td>&nbsp;
  317. <td>none
  318. <td>&nbsp;
  319. <td>(determined by operating system)
  320. <td>&nbsp;
  321. <td>6
  322. <tr valign=top> <td>image
  323. <td>&nbsp;
  324. <td>65535
  325. <td>&nbsp;
  326. <td>values (samples × components)<br>for1-, 2-, 4-, or 8-bit samples
  327. <td>&nbsp;
  328. <td>3300
  329. <tr valign=top> <td>&nbsp;
  330. <td>&nbsp;
  331. <td>32767
  332. <td>&nbsp;
  333. <td>values for 12-bit samples
  334. <td>&nbsp;
  335. <td>3300
  336. </table></blockquote>
  337. <h3><a name="VM_consumption"></a>Other differences in VM consumption</h3>
  338. <p>
  339. Packed array elements occupy either 2 bytes or 8 bytes. The average
  340. element size is probably about 5 bytes. Names occupy 12 bytes plus the
  341. space for the string.
  342. <hr>
  343. <h2><a name="Additional_operators"></a>Additional operators in Ghostscript</h2>
  344. <h3><a name="Graphics_and_text"></a>Graphics and text operators</h3>
  345. <h4><a name="Transparency"></a>Transparency</h4>
  346. <p>
  347. Ghostscript provides a set of operators for implementing the transparency
  348. and compositing facilities of PDF 1.4. These are defined only if the
  349. <b><tt>transpar</tt></b> option was selected when Ghostscript was built. We
  350. do not attempt to explain the underlying graphics model here: for details,
  351. see <a
  352. href="http://partners.adobe.com/asn/developer/technotes.html#acrobat-pdf"
  353. class="offsite">Adobe
  354. Technical Note</a> #5407, "<a
  355. href="http://partners.adobe.com/asn/developer/acrosdk/DOCS/PDF_Transparency.pdf"
  356. class="offsite">Transparency
  357. in PDF</a>". Note, however, that
  358. Ghostscript's model generalizes that of PDF 1.4 in that Ghostscript
  359. maintains separate alpha and mask values for opacity and shape, rather than
  360. a single value with a Boolean that says whether it represents opacity or
  361. shape. EVERYTHING IN THIS SECTION IS SUBJECT TO CHANGE.
  362. <h5><a name="Transparency_graphics_state_operators"></a>Graphics state
  363. operators</h5>
  364. <dl>
  365. <dt><b><tt>&lt;modename&gt; .setblendmode -</tt></b>
  366. <dd>Sets the blending mode in the graphics state. If the mode name is not
  367. recognized, causes a <b><tt>rangecheck</tt></b> error. The initial value of
  368. the blending mode is <b><tt>/Compatible</tt></b>.
  369. </dl>
  370. <dl>
  371. <dt><b><tt>- .currentblendmode &lt;modename&gt;</tt></b>
  372. <dd>Returns the current blending mode.
  373. </dl>
  374. <dl>
  375. <dt><b><tt>&lt;0..1&gt; .setopacityalpha -</tt></b>
  376. <dd>Sets the opacity alpha value in the graphics state.
  377. The initial opacity alpha value is 1.
  378. </dl>
  379. <dl>
  380. <dt><b><tt>- .currentopacityalpha &lt;0..1&gt;</tt></b>
  381. <dd>Returns the current opacity alpha value.
  382. </dl>
  383. <dl>
  384. <dt><b><tt>&lt;0..1&gt; .setshapealpha -</tt></b>
  385. <dd>Sets the shape alpha value in the graphics state.
  386. The initial shape alpha value is 1.
  387. </dl>
  388. <dl>
  389. <dt><b><tt>- .currentshapealpha &lt;0..1&gt;</tt></b>
  390. <dd>Returns the current shape alpha value.
  391. </dl>
  392. <dl>
  393. <dt><b><tt>&lt;bool&gt; .settextknockout -</tt></b>
  394. <dd>Sets the text knockout flag in the graphics state.
  395. The initial value of the text knockout flag is <b><tt>true</tt></b>.
  396. </dl>
  397. <dl>
  398. <dt><b><tt>- .currenttextknockout &lt;bool&gt;</tt></b>
  399. <dd>Returns the current text knockout flag.
  400. </dl>
  401. <h5><a name="Transparency_rendering_stack_operators"></a>Rendering stack
  402. operators</h5>
  403. <p>
  404. The interpreter state is extended to include a (per-context) rendering stack
  405. for handling transparency groups and masks (generically, "layers"). Groups
  406. accumulate a full value for each pixel (paint plus transparency); masks
  407. accumulate only a coverage value. Layers must be properly nested, i.e., the
  408. 'end' or 'discard' operator must match the corresponding 'begin' operator.
  409. <p>
  410. Beginning and ending layers must nest properly with respect to
  411. <b><tt>save</tt></b> and <b><tt>restore</tt></b>: <b><tt>save</tt></b> and
  412. <b><tt>restore</tt></b> do not save and restore the layer stack. Currently,
  413. layers are not required to nest with respect to <b><tt>gsave</tt></b> and
  414. <b><tt>grestore</tt></b>, except that the device that is current in the
  415. graphics state when ending a layer must be the same as the device that was
  416. current when beginning the layer. THIS AREA IS SUBJECT TO CHANGE.
  417. <dl>
  418. <dt><b><tt>&lt;paramdict&gt; &lt;llx&gt; &lt;lly&gt; &lt;urx&gt; &lt;ury&gt;
  419. .begintransparencygroup -</tt></b>
  420. <dd>Begins a new transparency group. The <b><tt>ll/ur</tt></b> coordinates
  421. are the bounding box of the group in the current user coordinate system.
  422. <b><tt>paramdict</tt></b> has the following keys:
  423. <dl>
  424. <dt><b><tt>/Isolated</tt></b>
  425. <dd>(optional) Boolean; default value = <b><tt>false</tt></b>.
  426. <dt><b><tt>/Knockout</tt></b>
  427. <dd>(optional) Boolean; default value = <b><tt>false</tt></b>.
  428. </dl>
  429. </dl>
  430. <dl>
  431. <dt><b><tt>- .discardtransparencygroup -</tt></b>
  432. <dd>Ends and discards the current transparency group.
  433. </dl>
  434. <dl>
  435. <dt><b><tt>- .endtransparencygroup -</tt></b>
  436. <dd>Ends the current transparency group, compositing the group being ended
  437. onto the group that now becomes current.
  438. </dl>
  439. <dl>
  440. <dt><b><tt>&lt;paramdict&gt; &lt;llx&gt; &lt;lly&gt; &lt;urx&gt; &lt;ury&gt;
  441. .begintransparencymask -</tt></b>
  442. <dd>Begins a new transparency mask. The <b><tt>ll/ur</tt></b> coordinates
  443. are the bounding box of the mask in the current user coordinate system.
  444. <b><tt>paramdict</tt></b> has the following keys:
  445. <dl>
  446. <dt><b><tt>/Subtype</tt></b>
  447. <dd>(required) Name, either <b><tt>/Alpha</tt></b> or
  448. <b><tt>/Luminosity</tt></b>.
  449. <dt><b><tt>/Background</tt></b>
  450. <dd>(optional) Array of number.
  451. <dt><b><tt>/TransferFunction</tt></b>
  452. <dd>(optional) Function object (produced by applying
  453. <b><tt>.buildfunction</tt></b> to a Function dictionary).
  454. </dl>
  455. </dl>
  456. <dl>
  457. <dt><b><tt>- .discardtransparencymask -</tt></b>
  458. <dd>Ends and discards the current transparency mask.
  459. </dl>
  460. <dl>
  461. <dt><b><tt>&lt;masknum&gt; .endtransparencymask -</tt></b>
  462. <dd>Ends the current transparency mask, installing it as the current opacity
  463. (<b><tt>masknum</tt></b> = 0) or shape (<b><tt>masknum</tt></b> = 1) mask in
  464. the graphics state.
  465. </dl>
  466. <dl>
  467. <dt><b><tt>&lt;masknum&gt; .inittransparencymask -</tt></b>
  468. <dd>Resets the current opacity (<b><tt>masknum</tt></b> = 0) or shape
  469. (<b><tt>masknum</tt></b> = 1) mask to an infinite mask with alpha = 1
  470. everywhere.
  471. </dl>
  472. <h5><a name="Transparency_ImageType"></a>New ImageType</h5>
  473. <p>
  474. The transparency extension defines a new ImageType 103, similar to ImageType
  475. 3 with the following differences:
  476. <ul>
  477. <li>The required <b><tt>MaskDict</tt></b> is replaced by two optional
  478. dictionaries, <b><tt>OpacityMaskDict</tt></b> and
  479. <b><tt>ShapeMaskDict</tt></b>. If present, these dictionaries must have a
  480. <b><tt>BitsPerComponent</tt></b> entry, whose value may be greater than 1.
  481. Note that in contrast to ImageType 3, where any non-zero chunky mask value
  482. is equivalent to 1, ImageType 103 simply takes the low-order bits of chunky
  483. mask values.
  484. <li>A <b><tt>Matte</tt></b> entry may be present in one or both mask
  485. dictionaries, indicating premultiplication of the data values. If both
  486. <b><tt>MaskDict</tt></b>s have a <b><tt>Matte</tt></b> entry and the values
  487. of the two <b><tt>Matte</tt></b> entries are different, a
  488. <b><tt>rangecheck</tt></b> error occurs.
  489. <li><b><tt>InterleaveType</tt></b> appears in the <b><tt>MaskDict</tt></b>s,
  490. not the <b><tt>DataDict</tt></b>, because each mask has its own
  491. <b><tt>InterleaveType</tt></b>. <b><tt>InterleaveType</tt></b> 2
  492. (interlaced scan lines) is not supported.
  493. </ul>
  494. <h4><a name="Graphics_state"></a>Other graphics state operators</h4>
  495. <dl>
  496. <dt><b><tt>&lt;bool&gt; .setaccuratecurves -</tt></b>
  497. <dd>Sets a graphics state flag that determines whether curves and arcs,
  498. when flattened, always start and end with a line that is a segment of the
  499. tangent; this also causes butt and square caps to be properly perpendicular
  500. to the tangent. <b><tt>initgraphics</tt></b> sets this flag to false, to
  501. match other PostScript implementations.
  502. </dl>
  503. <dl>
  504. <dt><b><tt>- .currentaccuratecurves &lt;bool&gt;</tt></b>
  505. <dd>Returns the current value of the accurate curves flag.
  506. </dl>
  507. <dl>
  508. <dt><b><tt>&lt;int&gt; .setcurvejoin -</tt></b>
  509. <dd>Sets a graphics state parameter that determines how to treat the joins
  510. between the line segments produced when a curve is flattened. The parameter
  511. value may be either -1 or a value acceptable to <b><tt>setlinejoin</tt></b>.
  512. If the parameter value is -1, the join used for flattened curve line
  513. segments is given by the current line join parameter in the graphics state
  514. (except that if the line join value is "none", a bevel join is used), which
  515. matches the Adobe Red Book, but not the Adobe implementations; if the curve
  516. join parameter value is a line join value, that type of join is used for
  517. flattened curve line segments, regardless of the value of the graphics state
  518. line join parameter. The initial (and default) value of the curve join
  519. parameter is 2, causing bevel joins to be used: this matches the Adobe
  520. implementations. <b><tt>initgraphics</tt></b> sets the parameter to its
  521. default value.
  522. </dl>
  523. <dl>
  524. <dt><b><tt>- .currentcurvejoin &lt;int&gt;</tt></b>
  525. <dd>Returns the current value of the curve join parameter.
  526. </dl>
  527. <dl>
  528. <dt><b><tt>&lt;bool&gt; .setdashadapt -</tt></b>
  529. <dd>Sets a graphics state flag that determines whether dash patterns do
  530. (true) or do not (false) automatically scale themselves so that each line
  531. segment consists of an integral number of pattern repetitions.
  532. <b><tt>initgraphics</tt></b> sets this flag to false.
  533. </dl>
  534. <dl>
  535. <dt><b><tt>- .currentdashadapt &lt;bool&gt;</tt></b>
  536. <dd>Returns the current value of the dash adaptation flag.
  537. </dl>
  538. <dl>
  539. <dt><b><tt>&lt;matrix&gt; .setdefaultmatrix -</tt></b>
  540. <dd>Sets the default matrix that is returned by
  541. <b><tt>defaultmatrix</tt></b> and installed by <b><tt>initmatrix</tt></b>.
  542. Ordinary programs should not use this operator.
  543. </dl>
  544. <dl>
  545. <dt><b><tt>&lt;num&gt; &lt;bool&gt; .setdotlength -</tt></b>
  546. <dd>Sets a graphics state parameter that determines the handling of
  547. zero-length lines (dots). If the dot length is zero, dots are painted as
  548. circles if round line caps are in effect, otherwise they are not painted at
  549. all. If the dot length is non-zero, dots are treated exactly like lines of
  550. the given length: the length is specified in user coordinates (like line
  551. width) if <b><tt>bool</tt></b> is false, or in default user coordinates of
  552. points (units of 1/72in; see the <a href="Devices.htm#Measurements">notes
  553. on measurements</a> in the documentation on devices) if
  554. <b><tt>bool</tt></b> is true. Dots occurring as part of dash patterns will
  555. be oriented correctly; isolated dots will be oriented as though they were
  556. part of a vertical line. <b><tt>initgraphics</tt></b> sets the dot length
  557. to zero.
  558. </dl>
  559. <dl>
  560. <dt><b><tt>- .currentdotlength &lt;num&gt; &lt;bool&gt;</tt></b>
  561. <dd>Returns the current dot length and dot length mode.
  562. </dl>
  563. <dl>
  564. <dt><b><tt>&lt;dx&gt; &lt;dy&gt; .setfilladjust2 -</tt></b>
  565. <dd>Sets graphics state parameters that cause all filled and stroked
  566. regions to be "fattened" by the given amount relative to an algorithm that
  567. only paints pixels whose centers fall within the region to be painted.
  568. <b><tt>dx</tt></b> and <b><tt>dy</tt></b> are numbers between 0 and 0.5,
  569. measured in device space. The only two values that are likely to be useful
  570. are 0, which gives a pure center-of-pixel rule, and 0.5, which gives
  571. Adobe's any-part-of-pixel rule. (0.5 is treated slightly specially in
  572. order to create half-open pixels per Adobe's specification.)
  573. </dl>
  574. <dl>
  575. <dt><b><tt>- .currentfilladjust2 &lt;dx&gt; &lt;dy&gt;</tt></b>
  576. <dd>Returns the current fill adjustment values.
  577. </dl>
  578. <dl>
  579. <dt><b><tt>&lt;bool&gt; .setlimitclamp -</tt></b>
  580. <dd>Sets a graphics state flag that determines whether attempts to set the
  581. current point outside the internally representable range should clamp the
  582. value to the largest representable value (true) or give a
  583. <b><tt>limitcheck</tt></b> error (false). <b><tt>initgraphics</tt></b> sets
  584. this flag to false, to match other PostScript implementations.
  585. </dl>
  586. <dl>
  587. <dt><b><tt>- .currentlimitclamp &lt;bool&gt;</tt></b>
  588. <dd>Returns the current value of the limit clamp flag.
  589. </dl>
  590. <dl>
  591. <dt><b><tt>&lt;int&gt; .setoverprintmode -</tt></b>
  592. <dd>Sets the overprint mode in the graphics state. Legal values are 0 or 1.
  593. Per the PDF 1.3 specification, if the overprint mode is 1, then when the
  594. current color space is <b><tt>DeviceCMYK</tt></b>, color components whose
  595. value is 0 do not write into the target, rather than writing a 0 value.
  596. THIS BEHAVIOR IS NOT IMPLEMENTED YET. The initial value of the overprint
  597. mode is 0.
  598. </dl>
  599. <dl>
  600. <dt><b><tt>- .currentoverprintmode &lt;int&gt;</tt></b>
  601. <dd>Returns the current overprint mode.
  602. </dl>
  603. <h4><a name="Path"></a>Path operators</h4>
  604. <dl>
  605. <dt><b><tt>- .dashpath -</tt></b>
  606. <dd>If there is no current dash pattern, does nothing. Otherwise, does the
  607. equivalent of <b><tt>flattenpath</tt></b> and then chops up the path as
  608. determined by the dash pattern.
  609. </dl>
  610. <dl>
  611. <dt><b><tt>&lt;x&gt; &lt;y&gt; &lt;width&gt; &lt;height&gt; .rectappend -</tt></b>
  612. <dt><b><tt>&lt;numarray&gt; .rectappend -</tt></b>
  613. <dt><b><tt>&lt;numstring&gt; .rectappend -</tt></b>
  614. <dd>Appends a rectangle or rectangles to the current path, in the same
  615. manner as <b><tt>rectfill</tt></b>, <b><tt>rectclip</tt></b>, etc. Defined
  616. only if the <b><tt>dps</tt></b> or <b><tt>level2</tt></b> option was
  617. selected when Ghostscript was built.
  618. </dl>
  619. <h4><a name="Painting"></a>Painting operators</h4>
  620. <p>
  621. Ghostscript supports an experimental extension of the PostScript imaging
  622. model to include <b><tt>RasterOp</tt></b> and some related facilities.
  623. This extension is available only if the <b><tt>rasterop</tt></b> option was
  624. selected when building Ghostscript.
  625. <p>
  626. With the <b><tt>RasterOp</tt></b> extension, imaging operations compute a
  627. function <b>D&nbsp;=&nbsp;f(D,S,T)</b> in RGB space, where <b>f</b> is an
  628. arbitrary 3-input Boolean function, <b>D</b> is the destination (frame
  629. buffer or print buffer), <b>S</b> is the source (described below), and
  630. <b>T</b> is the texture (the current PostScript color, which may be a
  631. pattern). The source and texture depend on the PostScript imaging
  632. operation:
  633. <ul>
  634. <li>For <b><tt>fill</tt></b> and <b><tt>stroke</tt></b>, the source is
  635. solid black, covering the region to be painted; the texture is the current
  636. PostScript color.
  637. <li>For <b><tt>show</tt></b> and <b><tt>imagemask</tt></b>, the source is
  638. solid black, covering the pixels to be painted; the texture is the current
  639. PostScript color.
  640. <li>For <b><tt>image</tt></b> and <b><tt>colorimage</tt></b>, the source is
  641. the image data; the texture depends on an optional Boolean parameter,
  642. <b><tt>CombineWithColor</tt></b>, in the image dictionary. If
  643. <b><tt>CombineWithColor</tt></b> is false (the default), the texture is
  644. solid black. If <b><tt>CombineWithColor</tt></b> is true, the texture is
  645. the current color. For the non-dictionary form of the image operator,
  646. <b><tt>CombineWithColor</tt></b> is considered to be false.
  647. </ul>
  648. <p>
  649. The <b><tt>rasterop</tt></b> option adds the following operators:
  650. <dl>
  651. <dt><b><tt>&lt;int8&gt; .setrasterop -</tt></b>
  652. <dd>Sets the <b><tt>RasterOp</tt></b> function in the graphics state. The
  653. default function is 252, Source | Texture.
  654. </dl>
  655. <dl>
  656. <dt><b><tt>- .currentrasterop &lt;int8&gt;</tt></b>
  657. <dd>Returns the current <b><tt>RasterOp</tt></b> function.
  658. </dl>
  659. <dl>
  660. <dt><b><tt>&lt;bool&gt; .setsourcetransparent -</tt></b>
  661. <dd>Sets source transparency in the graphics state. When source
  662. transparency is true, white source pixels prevent storing into the
  663. destination, regardless of what the <b><tt>RasterOp</tt></b> function
  664. returns. The default source transparency is false.
  665. </dl>
  666. <dl>
  667. <dt><b><tt>- .currentsourcetransparent &lt;bool&gt; -</tt></b>
  668. <dd>Returns the current source transparency.
  669. </dl>
  670. <dl>
  671. <dt><b><tt>&lt;bool&gt; .settexturetransparent -</tt></b>
  672. <dd>Sets texture transparency in the graphics state. When texture
  673. transparency is true, white texture pixels prevent storing into the
  674. destination, regardless of what the <b><tt>RasterOp</tt></b> function
  675. returns. The default texture transparency is false.
  676. </dl>
  677. <dl>
  678. <dt><b><tt>- .currenttexturetransparent &lt;bool&gt; -</tt></b>
  679. <dd>Returns the current texture transparency.
  680. </dl>
  681. <p>
  682. For more information on RasterOp and transparency, please consult chapter 5
  683. of the "PCL 5 Color Technical Reference Manual",
  684. <a href="http://www.hp.com/cposupport/printers/support_doc/bpl01354.html">Hewlett-Packard
  685. Manual Part No. 5961-0635</a>.
  686. <h4><a name="Character"></a>Character operators</h4>
  687. <dl>
  688. <dt><b><tt>&lt;string&gt; &lt;bool&gt; .charboxpath -</tt></b>
  689. <dd>For each character <b>C</b> in the rendering of &lt;string&gt;, let the
  690. bounding box of <b>C</b> <b><em>in device space</em></b> be the four
  691. <b><em>user-space</em></b> points p1x/y, p2x/y, p3x/y, and p4x/y. For each
  692. character in order, <b><tt>.charboxpath</tt></b> appends the following to
  693. the current path:
  694. <ul><li>If <b><tt>&lt;bool&gt;</tt></b> is true, the equivalent of:
  695. <blockquote>
  696. p1x p1y <b><tt>moveto</tt></b><br>
  697. p2x p2y <b><tt>lineto</tt></b><br>
  698. p3x p3y <b><tt>lineto</tt></b><br>
  699. p4x p4y <b><tt>lineto</tt></b><br>
  700. <b><tt>closepath</tt></b>
  701. </blockquote>
  702. </ul>
  703. <p>
  704. This creates a path whose <b><tt>pathbbox</tt></b> is the
  705. <b><tt>bbox</tt></b> of the string.
  706. <ul><li>If <b><tt>&lt;bool&gt;</tt></b> is false, the equivalent of:
  707. <blockquote>
  708. p1x p1y <b><tt>moveto</tt></b><br>
  709. p3x p3y <b><tt>lineto</tt></b>
  710. </blockquote>
  711. </ul>
  712. <p>
  713. If the CTM is well-behaved (consists only of reflection, scaling, and
  714. rotation by multiples of 90 degrees), this too creates a (simpler) path
  715. whose <b><tt>pathbbox</tt></b> is the <b><tt>bbox</tt></b> of the string.
  716. </dl>
  717. <dl>
  718. <dt><b><tt>&lt;font&gt; &lt;charname|charcode&gt; &lt;charname&gt; &lt;charstring&gt; .type1execchar -</tt></b>
  719. <dd>Does all the work for rendering a Type 1 outline. This operator, like
  720. <b><tt>setcharwidth</tt></b> and <b><tt>setcachedevice</tt></b>, is valid
  721. only in the context of a show operator -- that is, it must only be called
  722. from within a <b><tt>BuildChar</tt></b> or <b><tt>BuildGlyph</tt></b>
  723. procedure.
  724. </dl>
  725. <dl>
  726. <dt><b><tt>&lt;font&gt; &lt;charcode&gt; %Type1BuildChar -</tt></b>
  727. <dd>This is not a new operator: rather, it is a name known specially to the
  728. interpreter. Whenever the interpreter needs to render a character (during
  729. a ...<b><tt>show</tt></b>, <b><tt>stringwidth</tt></b>, or
  730. <b><tt>charpath</tt></b>), it looks up the name <b><tt>BuildChar</tt></b>
  731. in the font dictionary to find a procedure to run. If it does not find
  732. this name, and if the <b><tt>FontType</tt></b> is 1, the interpreter
  733. instead uses the value (looked up on the dictionary stack in the usual way)
  734. of the name <b><tt>%Type1BuildChar</tt></b>.
  735. <p>
  736. The standard definition of <b><tt>%Type1BuildChar</tt></b> is in the
  737. initialization file <b><tt>gs_type1.ps</tt></b>. Users should not need to
  738. redefine <b><tt>%Type1BuildChar</tt></b>, except perhaps for tracing or
  739. debugging.
  740. </dl>
  741. <dl>
  742. <dt><b><tt>&lt;font&gt; &lt;charname&gt; %Type1BuildGlyph -</tt></b>
  743. <dd>Provides the Type 1 implementation of <b><tt>BuildGlyph</tt></b>.
  744. </dl>
  745. <h3><a name="Other"></a>Other operators</h3>
  746. <h4><a name="Mathematical"></a>Mathematical operators</h4>
  747. <dl>
  748. <dt><b><tt>&lt;number&gt; arccos &lt;number&gt;</tt></b>
  749. <dd>Computes the arc cosine of a number between -1 and 1.
  750. </dl>
  751. <dl>
  752. <dt><b><tt>&lt;number&gt; arcsin &lt;number&gt;</tt></b>
  753. <dd>Computes the arc sine of a number between -1 and 1.
  754. </dl>
  755. <h4><a name="Dictionary"></a>Dictionary operators</h4>
  756. <dl>
  757. <dt><b><tt>mark &lt;key1&gt; &lt;value1&gt; &lt;key2&gt; &lt;value2&gt; ... .dicttomark &lt;dict&gt;</tt></b>
  758. <dd>Creates and returns a dictionary with the given keys and values. This
  759. is the same as the PostScript Level 2 <b><tt>&gt;&gt;</tt></b> operator,
  760. but is available even in Level 1 configurations.
  761. </dl>
  762. <dl>
  763. <dt><b><tt>&lt;dict&gt; &lt;key&gt; &lt;value&gt; .forceput - </tt></b>
  764. <dd>Equivalent to <b><tt>put</tt></b>, but works even if
  765. <b><tt>dict</tt></b> is not writable, and (if <b><tt>dict</tt></b> is
  766. <b><tt>systemdict</tt></b> or the current save level is 0) even if
  767. <b><tt>dict</tt></b> is in global VM and <b><tt>key</tt></b> and/or
  768. <b><tt>value</tt></b> is in local VM. <strong>This operator should be used
  769. only initialization code, and only in executeonly procedures: it must not be
  770. accessible after initialization.</strong>
  771. </dl>
  772. <dl>
  773. <dt><b><tt>&lt;dict&gt; &lt;key&gt; .forceundef - </tt></b>
  774. <dd>Equivalent to <b><tt>undef</tt></b>, but works even if
  775. <b><tt>dict</tt></b> is not writable. <strong>This operator should be used
  776. only initialization code, and only in executeonly procedures: it must not be
  777. accessible after initialization.</strong>
  778. </dl>
  779. <dl>
  780. <dt><b><tt>&lt;dict&gt; &lt;key&gt; .knownget &lt;value&gt; true</tt></b>
  781. <dt><b><tt>&lt;dict&gt; &lt;key&gt; .knownget false</tt></b>
  782. <dd>Combines <b><tt>known</tt></b> and <b><tt>get</tt></b> in the
  783. obvious way.
  784. </dl>
  785. <dl>
  786. <dt><b><tt>&lt;dict&gt; &lt;integer&gt; .setmaxlength -</tt></b>
  787. <dd>Sets the capacity (<b><tt>maxlength</tt></b>) of a dictionary.
  788. Causes a <b><tt>dictfull</tt></b> error if the dictionary has more
  789. occupied entries than the requested capacity.
  790. </dl>
  791. <h4><a name="String"></a>String and name operators</h4>
  792. <dl>
  793. <dt><b><tt>&lt;integer&gt; .bytestring &lt;bytestring&gt;</tt></b>
  794. <dd>Allocates and returns a bytestring, a special data type that can be
  795. larger than the maximum size of a string (64K-1 bytes) and can be used in
  796. place of a string with a very few operators.
  797. </dl>
  798. <dl>
  799. <dt><b><tt>&lt;name&gt; .namestring &lt;string&gt;</tt></b>
  800. <dd>Returns the (read-only) string for a name.
  801. </dl>
  802. <dl>
  803. <dt><b><tt>&lt;obj&gt; &lt;pattern&gt; .stringmatch &lt;bool&gt;</tt></b>
  804. <dd>Matches <b><tt>obj</tt></b> against a pattern in which '*' matches 0 or
  805. more characters and '?' matches any single character. If
  806. <b><tt>obj</tt></b> is a string or a name, matches its characters against
  807. the pattern; if <b><tt>obj</tt></b> is of any other type, the result is
  808. <b><tt>true</tt></b> if the pattern is the single character "*" and
  809. <b><tt>false</tt></b> otherwise.
  810. </dl>
  811. <dl>
  812. <dt><b><tt>&lt;state&gt; &lt;fromString&gt; &lt;toString&gt; .type1encrypt &lt;newState&gt; &lt;toSubstring&gt;</tt></b>
  813. <dd>Encrypts <b><tt>fromString</tt></b> according to the algorithm for
  814. Adobe Type 1 fonts, writing the result into <b><tt>toString</tt></b>.
  815. <b><tt>toString</tt></b> must be at least as long as
  816. <b><tt>fromString</tt></b>, or a rangecheck error occurs.
  817. <b><tt>state</tt></b> is the initial state of the encryption algorithm (a
  818. 16-bit non-negative integer); <b><tt>newState</tt></b> is the new state of
  819. the algorithm.
  820. </dl>
  821. <dl>
  822. <dt><b><tt>&lt;state&gt; &lt;fromString&gt; &lt;toString&gt; .type1decrypt &lt;newState&gt; &lt;toSubstring&gt;</tt></b>
  823. <dd>Decrypts <b><tt>fromString</tt></b> according to the algorithm for
  824. Adobe Type 1 fonts, writing the result into <b><tt>toString</tt></b>.
  825. Other specifications are as for <b><tt>type1encrypt</tt></b>.
  826. </dl>
  827. <h4><a name="Relational"></a>Relational operators</h4>
  828. <dl>
  829. <dt><b><tt>&lt;number|string&gt; &lt;number|string&gt; max &lt;number|string&gt;</tt></b>
  830. <dd>Returns the larger of two numbers or strings.
  831. </dl>
  832. <dl>
  833. <dt><b><tt>&lt;number|string&gt; &lt;number|string&gt; min &lt;number|string&gt;</tt></b>
  834. <dd>Returns the smaller of two numbers or strings.
  835. </dl>
  836. <h4><a name="File"></a>File operators</h4>
  837. <dl>
  838. <dt><b><tt>&lt;file&gt; .filename &lt;string&gt; true</tt></b>
  839. <dt><b><tt>&lt;file&gt; .filename false</tt></b>
  840. <dd>If the file was opened by the <b><tt>file</tt></b> or
  841. <b><tt>.tempfile</tt></b> operator, returns the file name and
  842. <b><tt>true</tt></b>; if the file is a filter, returns
  843. <b><tt>false</tt></b>.
  844. </dl>
  845. <dl>
  846. <dt><b><tt>&lt;file&gt; .fileposition &lt;integer&gt; true</tt></b>
  847. <dd>Returns the position of <b><tt>file</tt></b>. Unlike the standard
  848. <b><tt>fileposition</tt></b> operator, which causes an error if the file is
  849. not positionable, <b><tt>.fileposition</tt></b> works on all files,
  850. including filters: for non-positionable files, it returns the total number
  851. of bytes read or written since the file was opened.
  852. </dl>
  853. <dl>
  854. <dt><b><tt>&lt;string&gt; findlibfile &lt;foundstring&gt; &lt;file&gt; true</tt></b>
  855. <dt><b><tt>&lt;string&gt; findlibfile &lt;string&gt; false</tt></b>
  856. <dd>Opens the file of the given name for reading, searching through
  857. directories <a href="Use.htm#Finding_files">as described in the usage
  858. documentation</a>. If the search fails, <b><tt>findlibfile</tt></b> simply
  859. pushes false on the stack and returns, rather than causing an error.
  860. </dl>
  861. <dl>
  862. <dt><b><tt>&lt;file&gt; &lt;string&gt; .peekstring &lt;substring&gt; &lt;filled_bool&gt;</tt></b>
  863. <dd>Reads bytes from a file like <b><tt>readstring</tt></b>, but also leaves
  864. the bytes in the file buffer so they will be read again by a subsequent read
  865. operation. Currently gives a <b><tt>rangecheck</tt></b> error if
  866. <b><tt>string</tt></b> is larger than the file's buffer.
  867. </dl>
  868. <a name=Tempfile></a>
  869. <dl>
  870. <dt><b><tt>&lt;prefix_string|null&gt; &lt;access_string&gt; .tempfile
  871. &lt;string&gt; &lt;file&gt;</tt></b>
  872. <dd>Creates and opens a temporary file
  873. like the <b><tt>file</tt></b> operator, also returning the file name. There
  874. are three cases for the <b><tt>&lt;prefix_string|null&gt;</tt></b> operand:
  875. <ul>
  876. <p>
  877. <li><b><tt>null</tt></b>: create the file in the same directory and with the
  878. same name conventions as other temporary files created by the Ghostscript
  879. implementation on this platform. E.g., the temporary file might be named
  880. <b><tt>/tmp/gs_a1234</tt></b>.
  881. <p>
  882. <li>A string that is not the beginning of an absolute file name (e.g., does
  883. not begin with <b><tt>.</tt></b> or <b><tt>/</tt></b> on Unix-like
  884. platforms): create the file in the standard temporary directory, but use the
  885. <b><tt>&lt;prefix_string&gt;</tt></b> as the first part of the file name.
  886. E.g., if <b><tt>&lt;prefix_string&gt;</tt></b> is <b><tt>xx</tt></b>, the
  887. temporary file might be named <b><tt>/tmp/xxa1234</tt></b>.
  888. <p>
  889. <li>A string that is the beginning of an absolute file name: use the
  890. <b><tt>&lt;prefix_string&gt;</tt></b> as the first part of the file name.
  891. E.g., if <b><tt>&lt;prefix_string&gt;</tt></b> is
  892. <b><tt>/my/tmpdir/zz</tt></b>, the temporary file might be named
  893. <b><tt>/my/tmpdir/zza1234</tt></b>.
  894. <p>
  895. When running in <b><tt>SAFER</tt></b> mode, the absolute path must
  896. be one of the strings on the list given by the <b><tt>PermitFileWriting</tt></b>
  897. userparameter. Temporary files created with <b><tt>.tempfile</tt></b> can
  898. be deleted when in SAFER mode, and can be renamed to one of the paths
  899. that is on <b>both</b> the PermitFileControl and PermitFileWriting
  900. paths.
  901. </ul>
  902. <p>
  903. It is intended that in some future version of Ghostscript, files opened with
  904. <b><tt>.tempfile</tt></b> will be closed and deleted automatically when
  905. Ghostscript exits; however, this is not currently the case.
  906. </dl>
  907. <dl>
  908. <dt><b><tt>&lt;file&gt; &lt;integer&gt; .unread -</tt></b>
  909. <dd>Pushes back the last-read character onto the front of the file. If the
  910. file is open only for writing, or if the integer argument is not the same
  911. as the last character read from the file, causes an <b><tt>ioerror</tt></b>
  912. error. May also cause an <b><tt>ioerror</tt></b> if the last operation on
  913. the file was not a reading operation. This operator is now deprecated:
  914. use <b><tt>.peekstring</tt></b> in new code.
  915. </dl>
  916. <p>
  917. Ghostscript also supports the following <b><tt>IODevice</tt></b> in
  918. addition to a subset of those defined in the Adobe documentation:
  919. <b><tt>%pipe%command</tt></b>, which opens a pipe on the given command.
  920. This is supported only on operating systems that provide
  921. <b><tt>popen</tt></b> (primarily Unix systems, and not all of those).
  922. <h4><a name="Virtual_memory"></a>Virtual memory operators</h4>
  923. <dl>
  924. <dt><b><tt>&lt;save&gt; .forgetsave -</tt></b>
  925. <dd>Cancels the effect of a save, making it as though the save never
  926. happened.
  927. </dl>
  928. <h4><a name="Miscellaneous"></a>Miscellaneous operators</h4>
  929. <dl>
  930. <dt><b><tt>&lt;obj1&gt; &lt;obj2&gt; ... &lt;objn&gt; &lt;n&gt; .execn ...</tt></b>
  931. <dd>This executes <b><tt>obj1</tt></b> through <b><tt>objn</tt></b> in that
  932. order, essentially equivalent to
  933. <blockquote><pre>
  934. &lt;obj1&gt; &lt;obj2&gt; ... &lt;objn&gt; &lt;n&gt; array astore {exec} forall
  935. </pre></blockquote>
  936. <p>
  937. except that it doesn't actually create the array.
  938. </dl>
  939. <dl>
  940. <dt><b><tt>&lt;string&gt; getenv &lt;string&gt; true</tt></b>
  941. <dt><b><tt>&lt;string&gt; getenv false</tt></b>
  942. <dd>Looks up a name in the shell environment. If the name is found,
  943. returns the corresponding value and true; if the name is not found, returns
  944. false.
  945. </dl>
  946. <dl>
  947. <dt><b><tt>&lt;name&gt; &lt;array&gt; .makeoperator &lt;operator&gt;</tt></b>
  948. <dd>Constructs and returns a new operator that is actually the given
  949. procedure in disguise. The name is only used for printing. The operator
  950. has the executable attribute.
  951. <p>
  952. Operators defined in this way do one other thing besides running the
  953. procedure: if an error occurs during the execution of the procedure, and
  954. there has been no net reduction in operand or dictionary stack depth, the
  955. operand or dictionary stack pointer respectively is reset to its position
  956. at the beginning of the procedure.
  957. </dl>
  958. <dl>
  959. <dt><b><tt>&lt;string&gt; &lt;boolean&gt; .setdebug -</tt></b>
  960. <dd>If the Ghostscript interpreter was built with the <b><tt>DEBUG</tt></b>
  961. flag set, sets or resets any subset of the debugging flags normally
  962. controlled by <b><tt>-Z</tt></b> in the command line. Has no effect
  963. otherwise.
  964. </dl>
  965. <dl>
  966. <dt><b><tt>- .oserrno &lt;errno&gt;</tt></b>
  967. <dd>Returns the error code for the most recent operating system error.
  968. </dl>
  969. <dl>
  970. <dt><b><tt>- .oserrorstring &lt;string&gt;</tt></b>
  971. <dd>Returns the error string for the most recent operating system error.
  972. </dl>
  973. <a name="Runandhide"></a>
  974. <dl>
  975. <dt><b><tt>&lt;array&gt; &lt;procedure&gt; .runandhide ... &lt;array&gt;</tt></b>
  976. <dd>Runs the <i><tt>&lt;procedure&gt;</tt></i> after removing the
  977. <i><tt>&lt;array&gt;</tt></i> from the stack. As long as <i><tt>&lt;array&gt;</tt></i>
  978. is not contained in any readable dictionaries or elsewhere on stacks, it
  979. will not be accessible to <i><tt>&lt;procedure&gt;</tt></i>.
  980. <p>
  981. This operator is intended to allow hiding a <i><tt>&lt;save&gt;</tt></i> object
  982. during execution of procedures or files that run in <b>SAFER</b> mode.
  983. If a <b><tt>save</tt></b> is performed prior to entering <b>SAFER</b> mode
  984. with <b><tt>.setsafe</tt></b>, using the save object as the operand to
  985. <b><tt>restore</tt></b> will return to <b>NOSAFER</b> mode. In order to
  986. prevent the procedures running in <b>SAFER</b> mode from being able to
  987. return to <b>NOSAFER</b> mode, this operator should be used.
  988. Upon return from the file or procedure <b><tt>restore</tt></b> can be used
  989. to return to <b>NOSAFER</b> mode.
  990. <p>
  991. <b>Note:</b> The array operand hidden during the execution of the file or
  992. procedure will be placed at the top of the operand stack which may be on
  993. top of objects that the file or procedure leaves on top of the stack.
  994. Thus removing objects below the array may be needed to prevent an
  995. <b><tt>invalidrestore</tt></b> error.
  996. <p>
  997. For example, in order for a script or job server to execute a file
  998. <tt>somefile.ps</tt> with the <b>SAFER</b> mode restrictions in place, returning
  999. to unrestricted <b>NOSAFER</b> mode when the procedure exits is as follows:
  1000. <pre>
  1001. Start Ghostscript with <b>-dNOSAFER</b>
  1002. ... % perform any device set up w/o restrictions
  1003. [ save ] % create a save object before SAFER
  1004. (somefile.ps) (r) file cvx % open the file to process
  1005. .setsafe % enter SAFER mode
  1006. .runandhide % run the file hiding the save object
  1007. count 1 roll % place array below anything left over
  1008. count 1 sub { pop } repeat % pop left over stuff
  1009. cleardictstack % prevent invalidrestore from dicts
  1010. 0 get restore % go back to NOSAFER mode
  1011. </pre>
  1012. Another refinement on the above would be to execute <b><tt>.runandhide</tt></b>
  1013. using <b><tt>stopped</tt></b> in order to report errors but continue processing.
  1014. </dl>
  1015. <dl>
  1016. <dt><b><tt>- .setsafe -</tt></b>
  1017. <dd>If Ghostscript is started with <b><tt>-dNOSAFER</tt></b> or
  1018. <b><tt>-dDELAYSAFER</tt></b>, this operator can be used to enter <b>SAFER</b>
  1019. mode (see <a href="Use.htm#Safer"><b>-dSAFER</b></a>)
  1020. <p>
  1021. <b>Note: </b>If <b><tt>-dPARANOIDSAFER</tt></b> was specified on the command
  1022. line, <b><tt>.setsafe</tt></b> also sets the <b><tt>PermitFileReading</tt></b>
  1023. parameter to an empty array.
  1024. <p>
  1025. Since <b>SAFER</b> mode is implemented with userparameters and device parameters,
  1026. it is possible to use <b><tt>save</tt></b> and <b><tt>restore</tt></b> before
  1027. and after <b><tt>.setsafe</tt></b> to return to <b>NOSAFER</b> mode, but care
  1028. should be taken to ensure that the <i><tt>save</tt></i> object is not
  1029. accessible to any procedures or file run in <b>SAFER</b> mode (see
  1030. <a href="#Runandhide"><b>.runandhide</b></a> above).
  1031. </dl>
  1032. <dl>
  1033. <dt><b><tt>- .locksafe -</tt></b>
  1034. <dd>
  1035. This operator sets the current device's <b><tt>.LockSafetyParams</tt></b>
  1036. and the <b><tt>LockFilePermissions</tt></b> user parameter true as well as
  1037. adding the paths on LIBPATH and FONTPATH and the paths given by the
  1038. system params /GenericResourceDir and /FontResourceDir to the current
  1039. PermitFileReading list of paths.
  1040. <p>
  1041. If Ghostscript is started with <b><tt>-dNOSAFER</tt></b> or
  1042. <b><tt>-dDELAYSAFER</tt></b>, this operator can be used to enter <b>SAFER</b>
  1043. mode with the current set of <b><tt>PermitFile...</tt></b> user parameters
  1044. in effect. Since <b><tt>.setsafe</tt></b> sets the <b><tt>PermitFileWriting</tt></b>
  1045. and <b><tt>PermitFileControl</tt></b> user parameters to empty arrays, a script
  1046. or job server that needs to enable certain paths for file Writing and/or Control
  1047. can use this operator to perform the locking needed to enter <b>SAFER</b> mode.
  1048. <p>
  1049. See also <a href="#LockSafetyParams">.LockSafetyParams</a> and
  1050. <a href="#User_parameters">User Parameters</a>.
  1051. <p>
  1052. </dl>
  1053. <h4><a name="Device"></a>Device operators</h4>
  1054. <dl>
  1055. <dt><b><tt>&lt;device&gt; copydevice &lt;device&gt;</tt></b>
  1056. <dd>Copies a device. The copy is writable and installable. The copy is
  1057. created in the current VM (local or global), usually local VM for executing
  1058. ordinary PostScript files.
  1059. </dl>
  1060. <dl>
  1061. <dt><b><tt>&lt;devicename&gt; finddevice &lt;device&gt;</tt></b>
  1062. <dd>Creates a default instance of a device specified by name. The instance
  1063. is created in global VM. If <b><tt>finddevice</tt></b> is called more than
  1064. once with the same device name, it creates the default instance the first
  1065. time, and returns the same instance thereafter.
  1066. </dl>
  1067. <dl>
  1068. <dt><b><tt>&lt;devicename&gt; findprotodevice &lt;device&gt;</tt></b>
  1069. <dd>Finds the prototype of a device specified by name. A prototype can be
  1070. used with <b><tt>.getdeviceparams</tt></b> or other parameter-reading
  1071. operators, but it is read-only and cannot be set with
  1072. <b><tt>setdevice</tt></b>: it must be copied first.
  1073. </dl>
  1074. <dl>
  1075. <dt><b><tt>&lt;device&gt; &lt;x&gt; &lt;y&gt; &lt;width&gt; &lt;max_height&gt; &lt;alpha?&gt; &lt;std_depth|null&gt; &lt;string&gt; .getbitsrect &lt;height&gt; &lt;substring&gt;</tt></b>
  1076. <dd>Reads a rectangle of rendered bits back from a device. This is only
  1077. guaranteed to be implemented for image devices (see below).
  1078. <b><tt>alpha?</tt></b> is 0 for no alpha, -1 for alpha first, 1 for alpha
  1079. last. <b><tt>std_depth</tt></b> is null for native pixels, number of bits
  1080. per component for a standard color space.
  1081. </dl>
  1082. <dl>
  1083. <dt><b><tt>&lt;index&gt; .getdevice &lt;device&gt;</tt></b>
  1084. <dd>Returns a device from the set of devices known to the system. The
  1085. first device, which is the default, is numbered 0. If the
  1086. <b><tt>index</tt></b> is out of range, causes a <b><tt>rangecheck</tt></b>
  1087. error. This device is actually a prototype, not a directly usable device,
  1088. and is marked read-only; it cannot have its parameters changed or be
  1089. installed as the current device.
  1090. </dl>
  1091. <dl>
  1092. <dt><b><tt>&lt;matrix&gt; &lt;width&gt; &lt;height&gt; &lt;palette&gt; makeimagedevice &lt;device&gt;</tt></b>
  1093. <dd>Makes a new device that accumulates an image in memory. <b><tt>
  1094. matrix</tt></b> is the initial transformation matrix: it must be orthogonal
  1095. (that is, [a&nbsp;0&nbsp;0&nbsp;b&nbsp;x&nbsp;y] or
  1096. [0&nbsp;a&nbsp;b&nbsp;0&nbsp;x&nbsp;y]). <b><tt>palette</tt></b> is a
  1097. string of 2^<small><sup><b>N</b></sup></small> or
  1098. 3&nbsp;&times;&nbsp;2^<small><sup><b>N</b></sup></small> elements,
  1099. specifying how the 2^<small><sup><b>N</b></sup></small> possible pixel
  1100. values will be interpreted. Each element is interpreted as a gray value,
  1101. or as RGB values, multiplied by 255. For example, if you want a monochrome
  1102. image for which 0=white and 1=black, the palette should be
  1103. <b><tt>&lt;ff&nbsp;00&gt;</tt></b>; if you want a 3-bit deep image with
  1104. just the primary colors and their complements (ignoring the fact that 3-bit
  1105. images are not supported), the palette might be <b><tt>&lt;000000 0000ff
  1106. 00ff00 00ffff ff0000 ff00ff ffff00 ffffff&gt;</tt></b>. At present, the
  1107. palette must contain exactly 2, 4, 16, or 256 entries, and must contain an
  1108. entry for black and an entry for white; if it contains any entries that
  1109. aren't black, white, or gray, it must contain at least the six primary
  1110. colors (red, green, blue, and their complements cyan, magenta, and yellow);
  1111. aside from this, its contents are arbitrary.
  1112. <p>
  1113. Alternatively, palette can be 16, 24, 32, or null (equivalent to 24).
  1114. These are interpreted as:
  1115. <blockquote><table cellpadding=0 cellspacing=0>
  1116. <tr valign=bottom>
  1117. <th valign=bottom align=left>Palette
  1118. <td>&nbsp;&nbsp;&nbsp;
  1119. <th valign=bottom align=left>Bits allocated per color
  1120. <tr> <td colspan=3><hr>
  1121. <tr valign=top> <td>16
  1122. <td>&nbsp;
  1123. <td>5 red, 6 green, 5 blue
  1124. <tr valign=top> <td>24
  1125. <td>&nbsp;
  1126. <td>8 red, 8 green, 8 blue
  1127. <tr valign=top> <td>32
  1128. <td>&nbsp;
  1129. <td>8C, 8M, 8Y, 8K
  1130. </table></blockquote>
  1131. <p>
  1132. Note that one can also make an image device (with the same palette as an
  1133. existing image device) by copying a device using the
  1134. <b><tt>copydevice</tt></b> operator.
  1135. </dl>
  1136. <dl>
  1137. <dt><b><tt>&lt;matrix&gt; &lt;width&gt; &lt;height&gt; &lt;palette&gt; &lt;word?&gt; makewordimagedevice &lt;device&gt;</tt></b>
  1138. <dd>Makes an image device as described above. <b><tt>word?</tt></b> is a
  1139. Boolean value indicating whether the data should be stored in a
  1140. word-oriented format internally. No ordinary PostScript programs should
  1141. use this operator.
  1142. </dl>
  1143. <dl>
  1144. <dt><b><tt>&lt;device&gt; &lt;index&gt; &lt;string&gt; copyscanlines &lt;substring&gt;</tt></b>
  1145. <dd>Copies one or more scan lines from an image device into a string,
  1146. starting at a given scan line in the image. The data is in the same format
  1147. as for the <b><tt>image</tt></b> operator. It is an error if the device is
  1148. not an image device or if the string is too small to hold at least one
  1149. complete scan line. Always copies an integral number of scan lines.
  1150. </dl>
  1151. <dl>
  1152. <dt><b><tt>&lt;device&gt; setdevice -</tt></b>
  1153. <dd>Sets the current device to the specified device. Also resets the
  1154. transformation and clipping path to the initial values for the device.
  1155. Signals an <b><tt>invalidaccess</tt></b> error if the device is a
  1156. prototype or if <a href="Language.htm#LockSafetyParams">.LockSafetyParams</a>
  1157. is true for the current device.
  1158. </dl>
  1159. <dl>
  1160. <dt><b><tt>- currentdevice &lt;device&gt;</tt></b>
  1161. <dd>Gets the current device from the graphics state.
  1162. </dl>
  1163. <dl>
  1164. <dt><b><tt>&lt;device&gt; getdeviceprops &lt;mark&gt; &lt;name1&gt; &lt;value1&gt; ... &lt;namen&gt; &lt;valuen&gt;</tt></b>
  1165. <dd>Gets the properties of a device. See the section on
  1166. <a href="#Device_parameters">device parameters</a> below for details.
  1167. </dl>
  1168. <dl>
  1169. <dt><b><tt>&lt;mark&gt; &lt;name1&gt; &lt;value1&gt; ... &lt;namen&gt; &lt;valuen&gt; &lt;device&gt; putdeviceprops &lt;device&gt;</tt></b>
  1170. <dd>Sets properties of a device. May cause <b><tt>undefined</tt></b>,
  1171. <b><tt>invalidaccess</tt></b>, <b><tt>typecheck</tt></b>, <b><tt>rangecheck</tt></b>, or
  1172. <b><tt>limitcheck</tt></b> errors.
  1173. </dl>
  1174. <dl>
  1175. <dt><b><tt>- flushpage -</tt></b>
  1176. <dd>On displays, flushes any buffered output, so that it is guaranteed to
  1177. show up on the screen; on printers, has no effect.
  1178. </dl>
  1179. <hr>
  1180. <h2><a name="Filters"></a>Filters</h2>
  1181. <h3><a name="Standard_filters"></a>Standard filters</h3>
  1182. <p>
  1183. In its usual configuration, Ghostscript supports all the standard PostScript
  1184. LanguageLevel 3 filters, both encoding and decoding, except that it does not
  1185. currently support:
  1186. <ul>
  1187. <li>the <b><tt>EarlyChange</tt></b> key in the <b><tt>LZWEncode</tt></b>
  1188. filter.
  1189. </ul>
  1190. <p>
  1191. Ghostscript also supports additional keys in the optional dictionary
  1192. operands for some filters. For the <b><tt>LZWDecode</tt></b> filter:
  1193. <dl>
  1194. <dt><b><tt>InitialCodeLength &lt;integer&gt;</tt></b> (default 8)
  1195. <dd>An integer between 2 and 11 specifying the initial number of data bits
  1196. per code. Note that the actual initial code length is 1 greater than this,
  1197. to allow for the reset and end-of-data code values.
  1198. </dl>
  1199. <dl>
  1200. <dt><b><tt>FirstBitLowOrder &lt;boolean&gt;</tt></b> (default false)
  1201. <dd>If true, codes appear with their low-order bit first.
  1202. </dl>
  1203. <dl>
  1204. <dt><b><tt>BlockData &lt;boolean&gt;</tt></b> (default false)
  1205. <dd>If true, the data is broken into blocks in the manner specified for the
  1206. GIF file format.
  1207. </dl>
  1208. <p>
  1209. For the <b><tt>CCITTFaxEncode</tt></b> and <b><tt>CCITTFaxDecode</tt></b>
  1210. filters:
  1211. <dl>
  1212. <dt><b><tt>DecodedByteAlign &lt;integer&gt;</tt></b> (default 1)
  1213. <dd>An integer <b>N</b> with the value 1, 2, 4, 8, or 16, specifying that
  1214. decoded data scan lines are always a multiple of <b>N</b> bytes. The
  1215. encoding filter skips data in each scan line from Columns to the next
  1216. multiple of <b>N</b> bytes; the decoding filter pads each scan line to a
  1217. multiple of <b>N</b> bytes.
  1218. </dl>
  1219. <h3><a name="Non_standard_filters"></a>Non-standard filters</h3>
  1220. <p>
  1221. In addition to the standard PostScript LanguageLevel 3 filters, Ghostscript
  1222. supports the following non-standard filters. Many of these filters are used
  1223. internally to implement standard filters or facilities; they are almost
  1224. certain to remain, in their present form or a backward-compatible one, in
  1225. future Ghostscript releases.
  1226. <dl>
  1227. <dt><b><tt>&lt;target&gt; /BCPEncode filter &lt;file&gt;</tt></b>
  1228. <dt><b><tt>&lt;source&gt; /BCPDecode filter &lt;file&gt;</tt></b>
  1229. <dd>Create filters that implement the Adobe Binary Communications Protocol.
  1230. See Adobe documentation for details.
  1231. </dl>
  1232. <dl>
  1233. <dt><b><tt>&lt;target&gt; &lt;seed_integer&gt; /eexecEncode filter &lt;file&gt;</tt></b>
  1234. <dd>Creates a filter for encrypting data into the encrypted format described
  1235. in the Adobe Type 1 Font Format documentation. The
  1236. <b><tt>seed_integer</tt></b> must be 55665 for the <b><tt>eexec</tt></b>
  1237. section of a font, or 4330 for a <b><tt>CharString</tt></b>. Note that for
  1238. the <b><tt>eexec</tt></b> section of a font, this filter produces binary
  1239. output and does not include the initial 4 (or <b><tt>lenIV</tt></b>) garbage
  1240. bytes.
  1241. </dl>
  1242. <dl>
  1243. <dt><b><tt>&lt;source&gt; &lt;seed_integer&gt; /eexecDecode filter &lt;file&gt;</tt></b>
  1244. <dt><b><tt>&lt;source&gt; &lt;dict&gt; /eexecDecode filter &lt;file&gt;</tt></b>
  1245. <dd>Creates a filter for decrypting data encrypted as described in the Adobe
  1246. Type 1 Font Format documentation. The <b><tt>seed_integer</tt></b> must be
  1247. 55665 or 4330 as described just above. Recognized dictionary keys are:
  1248. <blockquote>
  1249. <b><tt>seed &lt;16-bit integer&gt;</tt></b> (required)<br>
  1250. <b><tt>lenIV &lt;non-negative integer&gt;</tt></b> (default=4)
  1251. </blockquote>
  1252. </dl>
  1253. <dl>
  1254. <dt><b><tt>&lt;target&gt; /MD5Encode filter &lt;file&gt;</tt></b>
  1255. <dd>Creates a filter that produces the 16-byte MD5 digest of the input.
  1256. Note that no output is produced until the filter is closed.
  1257. </dl>
  1258. <dl>
  1259. <dt><b><tt>&lt;source&gt; &lt;hex_boolean&gt; /PFBDecode filter &lt;file&gt;</tt></b>
  1260. <dd>Creates a filter that decodes data in <b><tt>.PFB</tt></b> format, the
  1261. usual semi-binary representation for Type 1 font files on IBM PC and
  1262. compatible systems. If <b><tt>hex_boolean</tt></b> is true, binary packets
  1263. are converted to hex; if false, binary packets are not converted.
  1264. </dl>
  1265. <dl>
  1266. <dt><b><tt>&lt;target&gt; &lt;dict&gt; /PixelDifferenceEncode filter &lt;file&gt;</tt></b>
  1267. <dt><b><tt>&lt;source&gt; &lt;dict&gt; /PixelDifferenceDecode filter &lt;file&gt;</tt></b>
  1268. <dd>Implements the Predictor=2 pixel-differencing option of the LZW
  1269. filters. Recognized keys are:
  1270. <blockquote>
  1271. <b><tt>Colors &lt;integer&gt;</tt></b> (1 to 4, default=1)<br>
  1272. <b><tt>BitsPerComponent &lt;integer&gt;</tt></b> (1, 2, 4, or 8, default=8)<br>
  1273. <b><tt>Columns &lt;integer&gt;</tt></b> (&gt;= 0, required)
  1274. </blockquote>
  1275. <p>
  1276. See the Adobe <a
  1277. href="http://partners.adobe.com/asn/developer/acrosdk/DOCS/pdfspec.pdf"><em>Portable
  1278. Document Format Reference Manual</em></a> for details.
  1279. </dl>
  1280. <dl>
  1281. <dt><b><tt>&lt;target&gt; &lt;dict&gt; /PNGPredictorEncode filter &lt;file&gt;</tt></b>
  1282. <dt><b><tt>&lt;source&gt; &lt;dict&gt; /PNGPredictorDecode filter &lt;file&gt;</tt></b>
  1283. <dd>Implements the "filter" algorithms of the
  1284. <a href="http://www.libpng.org/pub/png/">Portable Network Graphics (PNG)
  1285. graphics format</a>. Recognized keys are:
  1286. <blockquote><table cellpadding=0 cellspacing=0>
  1287. <tr><th colspan=5 bgcolor="#CCCC00"><hr><font size="+1">Keys recognized in PNG filter algorithms</font><hr>
  1288. <tr valign=bottom>
  1289. <th align=left>Key
  1290. <td>&nbsp;&nbsp;
  1291. <th align=left>Range
  1292. <td>&nbsp;&nbsp;
  1293. <th align=left>Default
  1294. <tr> <td colspan=5><hr>
  1295. <tr valign=top> <td><b><tt>Colors &lt;integer&gt;</tt></b>
  1296. <td>&nbsp;&nbsp;&nbsp;
  1297. <td>1 to 16
  1298. <td>&nbsp;&nbsp;
  1299. <td>16
  1300. <tr valign=top> <td><b><tt>BitsPerComponent &lt;integer&gt;</tt></b>
  1301. <td>&nbsp;
  1302. <td>1, 2, 4, 8, or 16
  1303. <td>&nbsp;&nbsp;
  1304. <td>8
  1305. <tr valign=top> <td><b><tt>Columns &lt;integer&gt;</tt></b>
  1306. <td>&nbsp;
  1307. <td>&gt;= 0
  1308. <td>&nbsp;&nbsp;
  1309. <td>1
  1310. <tr valign=top> <td><b><tt>Predictor &lt;integer&gt;</tt></b>
  1311. <td>&nbsp;
  1312. <td>10 to 15
  1313. <td>&nbsp;&nbsp;
  1314. <td>15
  1315. </table></blockquote>
  1316. <p>
  1317. The <b><tt>Predictor</tt></b> is the PNG algorithm number + 10 for the
  1318. <b><tt>Encoding</tt></b> filter; the <b><tt>Decoding</tt></b> filter
  1319. ignores <b><tt>Predictor</tt></b>. 15 means the encoder attempts to
  1320. optimize the choice of algorithm. For more details see the PNG
  1321. specification
  1322. <blockquote>
  1323. <a href="http://www.w3.org/TR/WD-png-960128.html">http://www.w3.org/TR/WD-png-960128.html</a>
  1324. </blockquote>
  1325. </dl>
  1326. <dl>
  1327. <dt><b><tt>&lt;target&gt; /TBCPEncode filter &lt;file&gt;</tt></b>
  1328. <dt><b><tt>&lt;source&gt; /TBCPDecode filter &lt;file&gt;</tt></b>
  1329. <dd>Create filters that implement the Adobe Tagged Binary Communications
  1330. Protocol. See Adobe documentation for details.
  1331. </dl>
  1332. <dl>
  1333. <dt><b><tt>&lt;target&gt; /zlibEncode filter &lt;file&gt;</tt></b>
  1334. <dt><b><tt>&lt;source&gt; /zlibDecode filter &lt;file&gt;</tt></b>
  1335. <dd>Creates filters that use the data compression method variously known as
  1336. 'zlib' (the name of a popular library that implements it), 'Deflate' (as in
  1337. <a href="http://www.ietf.org/rfc/rfc1951.txt">RFC 1951</a>, which is a
  1338. detailed specification for the method), 'gzip' (the name of a popular
  1339. compression application that uses it), or 'Flate' (Adobe's name). Note that
  1340. the PostScript <b><tt>Flate</tt></b> filters are actually a combination of
  1341. this filter with an optional predictor filter.
  1342. </dl>
  1343. <h3><a name="Unstable_filters"></a>Unstable filters</h3>
  1344. <p>
  1345. Some versions of Ghostscript may also support other non-standard filters for
  1346. experimental purposes. The current version includes the following such
  1347. filters, which are not documented further. No code should assume that these
  1348. filters will exist in compatible form, or at all, in future versions.
  1349. <dl>
  1350. <dt><b><tt>&lt;target/source&gt; &lt;string&gt; ByteTranslateEncode/Decode filter &lt;file&gt;</tt></b>
  1351. <dd><b><tt>string</tt></b> must be a string of exactly 256 bytes. Creates a
  1352. filter that converts each input byte <em>b</em> to
  1353. <b><tt>string</tt></b>[<em>b</em>]. Note that the <b><tt>Encode</tt></b>
  1354. and <b><tt>Decode</tt></b> filters operate identically: the client must
  1355. provide a <b><tt>string</tt></b> for the <b><tt>Decode</tt></b> filter that
  1356. is the inverse mapping of the <b><tt>string</tt></b> for the
  1357. <b><tt>Encode</tt></b> filter.
  1358. </dl>
  1359. <dl>
  1360. <dt><b><tt>&lt;target/source&gt; &lt;dict&gt; BoundedHuffmanEncode/Decode filter &lt;file&gt;</tt></b>
  1361. <dd>These filters encode and decode data using Huffman codes. Since these
  1362. filters aren't used anywhere, we don't document them further, except to note
  1363. the recognized dictionary keys, which must be set identically for encoding
  1364. and decoding:
  1365. <blockquote>
  1366. <b><tt>FirstBitLowOrder &lt;bool&gt;</tt></b> (default=false)<br>
  1367. <b><tt>MaxCodeLength &lt;int&gt;</tt></b> (default=16)<br>
  1368. <b><tt>EndOfData &lt;bool&gt;</tt></b> (default=true)<br>
  1369. <b><tt>EncodeZeroRuns &lt;int&gt;</tt></b> (default=256)<br>
  1370. <b><tt>Tables &lt;int_array&gt;</tt></b>
  1371. </blockquote>
  1372. </dl>
  1373. <dl>
  1374. <dt><b><tt>&lt;target/source&gt; &lt;dict&gt; BWBlockSortEncode/Decode filter &lt;file&gt;</tt></b>
  1375. <dd>This filter implements the Burroughs-Wheeler block sorting compression
  1376. method, which we've heard is also used in the popular <b><tt>bzip2</tt></b>
  1377. compression application. See <a
  1378. href="http://sources.redhat.com/bzip2/">http://sources.redhat.com/bzip2/</a>
  1379. for more information. The only recognized dictionary key is:
  1380. <blockquote>
  1381. <b><tt>BlockSize &lt;integer&gt;</tt></b> (default=16384)
  1382. </blockquote>
  1383. </dl>
  1384. <dl>
  1385. <dt><b><tt>&lt;target/source&gt; MoveToFrontEncode/Decode filter &lt;file&gt;</tt></b>
  1386. <dd>The <b><tt>Encode</tt></b> filter starts by initializing an internal
  1387. 256-byte array <b><tt>a</tt></b> to the values 0 .. 255. This array will
  1388. always hold a permutation of these values. Then for each input byte
  1389. <em>b</em>, the filter outputs the index <em>i</em> such that
  1390. <b><tt>a</tt></b>[<em>i</em>] = <em>b</em>, and moves that element to the
  1391. front (element 0) of <b><tt>a</tt></b>, moving elements 0 .. <em>i-1</em> to
  1392. positions 1 .. <em>i</em>. The <b><tt>Decode</tt></b> filter inverts this
  1393. process.
  1394. </dl>
  1395. <hr>
  1396. <h2><a name="Device_parameters"></a>Device parameters</h2>
  1397. Ghostscript supports the concept of device parameters for all devices, not
  1398. just page devices. (For non-page devices, these are accessible through
  1399. <b><tt>getdeviceprops</tt></b> and <b><tt>putdeviceprops</tt></b>, as
  1400. indicated above.) Here are the currently defined parameters for all
  1401. devices:
  1402. <dl>
  1403. <a name="LockSafetyParams"></a>
  1404. <dt><b><tt>.LockSafetyParams &lt;boolean&gt;</tt></b>
  1405. <dd>This parameter allows for improved system security by preventing
  1406. PostScript programs from being able to change potentially dangerous
  1407. device paramters such as OutputFile. This parameter cannot be set false
  1408. if it is already true.
  1409. <p>
  1410. If this parameter is true for the current device, attempt to set a new
  1411. device that has <b><tt>.LockSafetyParams</tt></b> false will signal an
  1412. <tt><b> invalidaccess</b></tt> error.
  1413. </dl>
  1414. <dl>
  1415. <dt><b><tt>BitsPerPixel &lt;integer&gt; (usually read-only)</tt></b>
  1416. <dd>Number of bits per pixel.
  1417. </dl>
  1418. <dl>
  1419. <dt><b><tt>.HWMargins [&lt;four floats&gt;]</tt></b>
  1420. <dd>Size of non-imageable regions around the edges of the page, in points
  1421. (units of 1/72in; see the <a href="Devices.htm#Measurements">notes on
  1422. measurements</a> in the documentation on devices).
  1423. </dl>
  1424. <dl>
  1425. <dt><b><tt>HWSize [&lt;integer&gt; &lt;integer&gt;]</tt></b>
  1426. <dd>X and Y size in pixels.
  1427. </dl>
  1428. <dl>
  1429. <dt><b><tt>Name &lt;string&gt; (read-only)</tt></b>
  1430. <dd>The device name. Currently the same as <b><tt>OutputDevice</tt></b>.
  1431. </dl>
  1432. <dl>
  1433. <dt><b><tt>Colors, GrayValues, RedValues, GreenValues, BlueValues, ColorValues (usually read-only)</tt></b>
  1434. <dd>As for the <b><tt>deviceinfo</tt></b> operator of Display PostScript.
  1435. <b><tt>Red</tt></b>, <b><tt>Green</tt></b>, <b><tt>Blue</tt></b>, and
  1436. <b><tt>ColorValues</tt></b> are only defined if
  1437. <b><tt>Colors</tt></b>&nbsp;&gt;&nbsp;1.
  1438. </dl>
  1439. <dl>
  1440. <dt><b><tt>TextAlphaBits, GraphicsAlphaBits (usually read-only)</tt></b>
  1441. <dd>The number of bits of anti-aliasing information for text or graphics
  1442. respectively. Legal values are 1 (no anti-aliasing, the default for most
  1443. devices), 2, or 4.
  1444. </dl>
  1445. <p>
  1446. In addition, the following are defined per Adobe's documentation for the
  1447. <b><tt>setpagedevice</tt></b> operator:
  1448. <blockquote>
  1449. <b><tt>Duplex</tt></b> (if supported)<br>
  1450. <b><tt>HWResolution</tt></b><br>
  1451. <b><tt>ImagingBBox</tt></b><br>
  1452. <b><tt>Margins</tt></b><br>
  1453. <b><tt>NumCopies</tt></b> (for printers only)<br>
  1454. <b><tt>Orientation</tt></b> (if supported)<br>
  1455. <b><tt>OutputDevice</tt></b><br>
  1456. <b><tt>PageOffset</tt></b> (write-only)<br>
  1457. <b><tt>PageSize</tt></b><br>
  1458. <b><tt>ProcessColorModel</tt></b> (usually read-only)<br>
  1459. </blockquote>
  1460. <p>
  1461. Some devices may only allow certain values for <b><tt>HWResolution</tt></b>
  1462. and <b><tt>PageSize</tt></b>. The null device ignores attempts to set
  1463. <b><tt>PageSize</tt></b>; its size is always <b><tt>[0&nbsp;0]</tt></b>.
  1464. <p>
  1465. For printers these are also defined:
  1466. <dl>
  1467. <dt><b><tt>BufferSpace &lt;integer&gt;</tt></b>
  1468. <dd>Buffer space for band lists, if the bitmap is too big to fit in memory.
  1469. </dl>
  1470. <dl>
  1471. <dt><b><tt>MaxBitmap &lt;integer&gt;</tt></b>
  1472. <dd>Maximum space for a full bitmap in memory.
  1473. </dl>
  1474. <dl>
  1475. <dt><b><tt>OutputFile &lt;string&gt;</tt></b>
  1476. <dd>An empty string means "send to printer directly", otherwise specifies
  1477. the file name for output; <b><tt>%d</tt></b> is replaced by the page number;
  1478. on Unix systems <b><tt>%pipe%</tt></b><em>command</em> writes to a pipe.
  1479. (<b><tt>|</tt></b><em>command</em> also writes to a pipe, but is now
  1480. deprecated.)
  1481. <p>
  1482. Attempts to set this parameter if <tt><b>.LockSafetyParams</b></tt> is true
  1483. will signal an <tt><b>invalidaccess</b></tt> error.
  1484. </dl>
  1485. <dl>
  1486. <dt><b><tt>OpenOutputFile &lt;boolean&gt;</tt></b>
  1487. <dd>If true, open the device's output file when the device is opened,
  1488. rather than waiting until the first page is ready to print.
  1489. </dl>
  1490. <dl>
  1491. <dt><b><tt>PageCount &lt;integer&gt; (read-only)</tt></b>
  1492. <dd>Counts the number of pages printed on the device.
  1493. </dl>
  1494. <p>
  1495. The following parameters are for use only by very specialized applications
  1496. that separate band construction from band rasterization. Improper use may
  1497. cause unpredictable errors. In particular, if you only want to allocate
  1498. more memory for banding, to increase band size and improve performance, use
  1499. the <b><tt>BufferSpace</tt></b> parameter, not
  1500. <b><tt>BandBufferSpace</tt></b>.
  1501. <dl>
  1502. <dt><b><tt>BandHeight &lt;integer&gt;</tt></b>
  1503. <dd>The height of bands when banding. 0 means use the largest band height
  1504. that will fit within the BandBufferSpace (or BufferSpace, if
  1505. BandBufferSpace is not specified).
  1506. </dl>
  1507. <dl>
  1508. <dt><b><tt>BandWidth &lt;integer&gt;</tt></b>
  1509. <dd>The width of bands in the rasterizing pass, in pixels. 0 means use the
  1510. actual page width.
  1511. </dl>
  1512. <dl>
  1513. <dt><b><tt>BandBufferSpace &lt;integer&gt;</tt></b>
  1514. <dd>The size of the band buffer in the rasterizing pass, in bytes. 0 means
  1515. use the same buffer size as for the interpretation pass.
  1516. </dl>
  1517. <p>
  1518. Ghostscript supports the following parameter for
  1519. <b><tt>setpagedevice</tt></b> and <b><tt>currentpagedevice</tt></b> that is
  1520. not a device parameter per se:
  1521. <dl>
  1522. <dt><b><tt>ViewerPreProcess &lt;procedure&gt;</tt></b>
  1523. <dd>Specifies a procedure to be applied to the page device dictionary
  1524. before any other processing is done. The procedure may not alter the
  1525. dictionary, but it may return a modified copy. This "hook" is provided for
  1526. use by viewing programs such as GSview.
  1527. </dl>
  1528. <hr>
  1529. <h2><a name="User_parameters"></a>User parameters</h2>
  1530. Ghostscript supports the following non-standard user parameters:
  1531. <dl>
  1532. <dt><b><tt>ProcessDSCComment &lt;procedure|null&gt;</tt></b>
  1533. <dd>If not null, this procedure is called whenever the scanner detects a DSC
  1534. comment (comment beginning with <b><tt>%%</tt></b> or <b><tt>%!</tt></b>).
  1535. There are two operands, the file and the comment (minus any terminating
  1536. EOL), which the procedure must consume.
  1537. </dl>
  1538. <dl>
  1539. <dt><b><tt>ProcessComment &lt;procedure|null&gt;</tt></b>
  1540. <dd>If not null, this procedure is called whenever the scanner detects a
  1541. comment (or, if <b><tt>ProcessDSCComment</tt></b> is also not null, a
  1542. comment other than a DSC comment). The operands are the same as for
  1543. <b><tt>ProcessDSCComment</tt></b>.
  1544. </dl>
  1545. <dl>
  1546. <dt><b><tt>LockFilePermissions &lt;boolean&gt;</tt></b>
  1547. <dd>If <tt>true</tt>, this parameter and the three <tt>PermitFile...</tt>
  1548. parameters cannot be changed. Attempts to change any of the values
  1549. when LockFilePermissions is <tt>true</tt> will signal <b><tt>invalidaccess</tt></b>.
  1550. Also, when this value is <tt>true</tt>, the <b><tt>file</tt></b> operator
  1551. will give <b><tt>invalidaccess</tt></b> when attempting to open files
  1552. (processes) using the <b><tt>%pipe</tt></b> device.
  1553. <p>
  1554. Also when <b><tt>LockFilePermissions</tt></b> is <tt>true</tt>, strings
  1555. cannot reference the parent directory (platform specific). For example
  1556. <b><tt>(../../xyz)</tt></b> is illegal on unix, Windows
  1557. and Macintosh, and <b><tt>([.#.#.XYZ])</tt></b> is illegal on VMS.
  1558. <p>
  1559. This parameter is set <tt>true</tt> by the <b><tt>.setsafe</tt></b> and
  1560. <b><tt>.locksafe</tt></b> operators.
  1561. </dl>
  1562. <dl>
  1563. <dt><b><tt>PermitFileReading &lt;array of strings&gt;</tt></b>
  1564. <dt><b><tt>PermitFileWriting &lt;array of strings&gt;</tt></b>
  1565. <dt><b><tt>PermitFileControl &lt;array of strings&gt;</tt></b>
  1566. <dd>These parameters specify paths where file reading, writing and the
  1567. 'control' operations are permitted, respectively. File control
  1568. operations are <b><tt>deletefile</tt></b> and <b><tt>renamefile</tt></b>.
  1569. For <b><tt>renamefile</tt></b>, the filename for the current filename
  1570. must match one of the paths on the PermitFileControl list, and the
  1571. new filename must be on <b>both</b> the PermitFileControl and the
  1572. PermitFileWriting lists of paths.
  1573. <p>
  1574. The strings can contain wildcard characters as for the <b><tt>filenameforall</tt></b>
  1575. operator and unless specifying a single file, will end with a <b>*</b>
  1576. for directories (folders) to allow access to all files and sub-directories
  1577. in that directory.
  1578. <p>
  1579. <b>Note:</b> The strings are used for stringmatch operations similar
  1580. to <b><tt>filenameforall</tt></b>, thus on MS Windows platforms, use the '/'
  1581. character to separate directories and filenames or use '\\\\' to
  1582. have the string contain '\\' which will match a single '\' in the
  1583. target filename (use of '/' is strongly recommended).
  1584. <p>
  1585. The <a href=Use.htm#Safer><b>SAFER</b></a> mode and the
  1586. <b><tt>.setsafe</tt></b> operator set all three lists to empty arrays,
  1587. thus the only files that can be read are the <b><tt>%stdin</tt></b> device and
  1588. on LIBPATH or FONTPATH or the Resource paths specified by the /FontResourceDir
  1589. or /GenericResourceDir system params. Files cannot be opened for writing
  1590. anywhere and cannot be deleted or renamed except for files created with the
  1591. <a href=#Tempfile><b>.tempfile</b></a> operator).
  1592. </dl>
  1593. <hr>
  1594. <h2><a name="Miscellaneous_additions"></a>Miscellaneous additions</h2>
  1595. <b><tt>run</tt></b> can take either a string or a file as its argument. In
  1596. the latter case, it just runs the file, closing it at the end, and trapping
  1597. errors just as for the string case.
  1598. <!-- [2.0 end contents] ==================================================== -->
  1599. <!-- [3.0 begin visible trailer] =========================================== -->
  1600. <hr>
  1601. <p>
  1602. <small>Copyright &copy; 1996, 2000 Aladdin Enterprises. All rights
  1603. reserved.</small>
  1604. <p>
  1605. <small>This file is part of AFPL Ghostscript. See the
  1606. <a href="Public.htm">Aladdin Free Public License</a> (the "License") for
  1607. full details of the terms of using, copying, modifying, and redistributing
  1608. AFPL Ghostscript.</small>
  1609. <p>
  1610. <small>Ghostscript version 7.04, 31 January 2002
  1611. <!-- [3.0 end visible trailer] ============================================= -->
  1612. </body>
  1613. </html>