/usr/share/ghostscript/8.70/lib
NameSizeModeActions
acctest.ps43240644editdlrm
addxchar.ps98480644editdlrm
align.ps23130644editdlrm
bdftops.ps234030644editdlrm
bj8.rpd6390644editdlrm
bj8gc12f.upp15280644editdlrm
bj8hg12f.upp15270644editdlrm
bj8oh06n.upp15130644editdlrm
bj8pa06n.upp15210644editdlrm
bj8pp12f.upp15380644editdlrm
bj8ts06n.upp15260644editdlrm
bjc610a0.upp15230644editdlrm
bjc610a1.upp15120644editdlrm
bjc610a2.upp15130644editdlrm
bjc610a3.upp15180644editdlrm
bjc610a4.upp15260644editdlrm
bjc610a5.upp15130644editdlrm
bjc610a6.upp15130644editdlrm
bjc610a7.upp15160644editdlrm
bjc610a8.upp15220644editdlrm
bjc610b1.upp15120644editdlrm
bjc610b2.upp15130644editdlrm
bjc610b3.upp15180644editdlrm
bjc610b4.upp15260644editdlrm
bjc610b6.upp15130644editdlrm
bjc610b7.upp15170644editdlrm
bjc610b8.upp15220644editdlrm
bjc6000a1.upp16600644editdlrm
bjc6000b1.upp16600644editdlrm
caption.ps17210644editdlrm
cbjc600.ppd110400644editdlrm
cbjc800.ppd113830644editdlrm
cdj550.upp16860644editdlrm
cdj690.upp19950644editdlrm
cdj690ec.upp20560644editdlrm
cid2code.ps44750644editdlrm
decrypt.ps3500644editdlrm
dmp_init.ps72460644editdlrm
dmp_site.ps4590644editdlrm
dnj750c.upp28040644editdlrm
dnj750m.upp19710644editdlrm
docie.ps73730644editdlrm
dumphint.ps200440644editdlrm
escp_24.src3500644editdlrm
font2c.ps195910644editdlrm
font2pcl.ps175680644editdlrm
ghostpdf.ppd256430644editdlrm
gslp.ps196430644editdlrm
gsnup.ps27250644editdlrm
gs_ce_e.ps23640644editdlrm
gs_cmdl.ps48440644editdlrm
gs_fform.ps31620644editdlrm
gs_il2_e.ps27770644editdlrm
gs_kanji.ps39420644editdlrm
gs_ksb_e.ps32910644editdlrm
gs_l.xbm19450644editdlrm
gs_l.xpm27510644editdlrm
gs_lgo_e.ps28860644editdlrm
gs_lgx_e.ps19120644editdlrm
gs_l_m.xbm19550644editdlrm
gs_m.xbm9450644editdlrm
gs_m.xpm14370644editdlrm
gs_m_m.xbm9550644editdlrm
gs_pfile.ps43490644editdlrm
gs_rdlin.ps8620644editdlrm
gs_s.xbm5940644editdlrm
gs_s.xpm9570644editdlrm
gs_s_m.xbm6040644editdlrm
gs_t.xbm3450644editdlrm
gs_t.xpm6050644editdlrm
gs_t_m.xbm3550644editdlrm
gs_wl1_e.ps25300644editdlrm
gs_wl2_e.ps25280644editdlrm
gs_wl5_e.ps25460644editdlrm
ht_ccsto.ps2281940644editdlrm
image-qa.ps733230644editdlrm
impath.ps55380644editdlrm
jispaper.ps9300644editdlrm
landscap.ps15250644editdlrm
level1.ps1100644editdlrm
lines.ps38680644editdlrm
markhint.ps34730644editdlrm
markpath.ps18900644editdlrm
mkcidfm.ps73050644editdlrm
necp2x.upp10410644editdlrm
necp2x6.upp10650644editdlrm
packfile.ps103580644editdlrm
pcharstr.ps35840644editdlrm
pdf2dsc.ps83770644editdlrm
PDFA_def.ps11700644editdlrm
pdfopt.ps365160644editdlrm
pdfwrite.ps116760644editdlrm
PDFX_def.ps18680644editdlrm
pf2afm.ps153510644editdlrm
pfbtopfa.ps11410644editdlrm
PM760p.upp11600644editdlrm
PM760pl.upp11240644editdlrm
PM820p.upp11420644editdlrm
PM820pl.upp11170644editdlrm
ppath.ps19740644editdlrm
pphs3910644editdlrm
pphs.ps69220644editdlrm
prfont.ps64870644editdlrm
printafm.ps37750644editdlrm
ps2ai.ps224850644editdlrm
ps2ascii.ps446180644editdlrm
ps2epsi.ps81870644editdlrm
quit.ps50644editdlrm
ras1.upp2110644editdlrm
ras3.upp2100644editdlrm
ras4.upp2160644editdlrm
ras8m.upp2050644editdlrm
ras24.upp2150644editdlrm
ras32.upp1920644editdlrm
rollconv.ps117650644editdlrm
s400a1.upp14540644editdlrm
s400b1.upp16030644editdlrm
sharp.upp19360644editdlrm
showchar.ps29320644editdlrm
showpage.ps90644editdlrm
sipixa6.upp5290644editdlrm
st640ih.upp22770644editdlrm
st640ihg.upp15040644editdlrm
st640p.upp19100644editdlrm
st640pg.upp11370644editdlrm
st640pl.upp18740644editdlrm
st640plg.upp11010644editdlrm
stc.upp19190644editdlrm
stc2.upp19000644editdlrm
stc2s_h.upp22680644editdlrm
stc2_h.upp18750644editdlrm
stc200_h.upp18440644editdlrm
stc300.upp21320644editdlrm
stc300bl.upp13370644editdlrm
stc300bm.upp14260644editdlrm
stc500p.upp18990644editdlrm
stc500ph.upp18990644editdlrm
stc600ih.upp22770644editdlrm
stc600p.upp11470644editdlrm
stc600pl.upp11110644editdlrm
stc640p.upp10910644editdlrm
Stc670p.upp11590644editdlrm
Stc670pl.upp11240644editdlrm
Stc680p.upp11400644editdlrm
Stc680pl.upp11150644editdlrm
stc740ih.upp21230644editdlrm
Stc740p.upp10390644editdlrm
Stc740pl.upp11150644editdlrm
Stc760p.upp11410644editdlrm
Stc760pl.upp11150644editdlrm
Stc777p.upp11400644editdlrm
Stc777pl.upp11150644editdlrm
stc800ih.upp21540644editdlrm
stc800p.upp11110644editdlrm
stc800pl.upp10930644editdlrm
stc1520h.upp21500644editdlrm
stcany.upp6690644editdlrm
stcany_h.upp6770644editdlrm
stcinfo.ps257330644editdlrm
stcolor.ps52210644editdlrm
stc_h.upp19090644editdlrm
stc_l.upp7300644editdlrm
stocht.ps26460644editdlrm
Stp720p.upp11580644editdlrm
Stp720pl.upp11150644editdlrm
Stp870p.upp11400644editdlrm
Stp870pl.upp11150644editdlrm
traceimg.ps15280644editdlrm
traceop.ps27340644editdlrm
type1enc.ps25360644editdlrm
type1ops.ps75760644editdlrm
uninfo.ps61360644editdlrm
unprot.ps19040644editdlrm
viewcmyk.ps21130644editdlrm
viewgif.ps45730644editdlrm
viewjpeg.ps49490644editdlrm
viewmiff.ps37780644editdlrm
viewpbm.ps53070644editdlrm
viewpcx.ps43450644editdlrm
viewps2a.ps12820644editdlrm
wftopfa.ps89230644editdlrm
winmaps.ps37430644editdlrm
wrfont.ps181680644editdlrm
zeroline.ps24630644editdlrm
Edit: /usr/share/ghostscript/8.70/lib/pdfopt.ps (36516B)
% Copyright (C) 2000, 2001 Aladdin Enterprises. All rights reserved. % % This software is provided AS-IS with no warranty, either express or % implied. % % This software is distributed under license and may not be copied, % modified or distributed except as expressly authorized under the terms % of the license contained in the file LICENSE in this distribution. % % For more information about licensing, please refer to % http://www.ghostscript.com/licensing/. For information on % commercial licensing, go to http://www.artifex.com/licensing/ or % contact Artifex Software, Inc., 101 Lucas Valley Road #110, % San Rafael, CA 94903, U.S.A., +1(415)492-9861. % $Id: pdfopt.ps 9390 2009-01-23 19:04:40Z alexcher $ % PDF linearizer ("optimizer"). .currentglobal true .setglobal /pdfoptdict 200 dict def pdfoptdict begin % This linearizer is designed for simplicity, not for performance. % See the main program (the last procedure in the file) for comments % describing the main processing sequence. % ---------------- Utilities ---------------- % % ------ Data structures ------ % % Distinguish dictionaries, arrays, and everything else. /ifdaelse { % ifdaelse - 3 index type dup /dicttype eq { pop pop pop } { dup /arraytype ne exch /packedarraytype ne and { exch } if pop exch pop } ifelse exec } bind def % Implement dynamically growable arrays using a dictionary. /darray { % darray dict } bind def /dadd { % dadd - 1 index length exch put } bind def /daforall { % daforall - /exch cvx /get cvx 3 -1 roll /exec cvx 5 packedarray cvx 0 1 2 index 0 get length 1 sub 4 -1 roll for } bind def /dacontents { % dacontents [ exch { } daforall ] } bind def /dacontstring { % dacontstring 0 1 index { exch pop length add } forall string dup /NullEncode filter % Stack: darray str filter 3 -1 roll { 1 index exch writestring } daforall closefile } bind def % Force an object, mapping it if it is a reference. /omforcenew { % omforce dup oforce 2 copy eq { pop true } { exch 0 get omapnew exch pop } ifelse } bind def /omforce { % omforce omforcenew pop } bind def /omget { % omget get omforce } bind def % Visit an entire tree. /omvisit { % omvisit - omforcenew { { { omvisit omvisit } forall } { { omvisit } forall } { pop } ifdaelse } { pop } ifelse } bind def % Visit a tree, stopping at references to Page objects. % (This is only needed for the OpenAction in the Catalog.) /omvisitnopage { % omvisitnopage - dup oforce dup type /dicttype eq { /Type .knownget { /Page eq } { false } ifelse } { pop false } ifelse { pop % Page reference } { omforcenew { { { omvisitnopage omvisitnopage } forall } { { omvisitnopage } forall } { pop } ifdaelse } { pop } ifelse } ifelse } bind def % Collect the list of currently mapped object numbers, in order. /omapped { % - omapped RMap ld_length larray exch lgrowto RMap { 2 index 3 1 roll 1 sub exch lput } ld_forall } bind def % Collect the list of object numbers passed to omap by a procedure. /visited { % visited false currentomap 2 .execn omapped exch setomap } bind def % ------ Output ------ % % Provide a framework for closure-based streams. .currentglobal false .setglobal userdict /clostreams 20 dict put % stream -> [data endproc] .setglobal % Create a closure-based stream. /clostream { % clostream 2 index 3 -1 roll /exec load 3 packedarray cvx /NullEncode filter % Stack: data endproc stream clostreams 1 index 5 -2 roll 2 array astore put } bind def % Close a closure-based stream. /closend { % closend dup closefile clostreams exch 2 copy get 3 1 roll undef aload pop exec } bind def % Implement in-memory output streams. /msproc { % msproc 3 -1 roll dadd { 100 string } { () } ifelse } bind def /mstream { % - mstream 10 darray {msproc} {dacontstring} clostream } bind def /mcontents { % mcontents closend } bind def % Implement a stream that only keeps track of its position. % (All streams should do this, but the PLRM doesn't require it.) /posbuf 100 string def /posproc { % posproc 0 2 copy get 5 -1 roll length add put pop //posbuf } bind def /postream { % - postream [0] {posproc} {0 get} clostream } bind def /poslength { % poslength closend } bind def % Implement streams with variable-bit-width data. % Note that these are dictionary objects, not stream objects. /bitstream { % bitstream 4 dict begin /S exch def /N 8 def /B 0 def currentdict end } bind def /bitwrite { % bitwrite - PDFOPTDEBUG { ( ) print 1 index =only (:) print dup = } if 3 -1 roll begin N exch sub dup 0 ge { /N exch def N bitshift B add } { 2 copy bitshift B add S exch write % Stack: value -left { 8 add dup 0 ge { exit } if 2 copy bitshift 255 and S exch write } loop /N 1 index def bitshift 255 and } ifelse /B exch def end } bind def /bitflush { % bitflush - begin N 8 ne { S B write /B 0 def /N 8 def } if end } bind def /bwn { % bwn - 2 copy % v w v w 2 exch exp ge { % v w v>=2**w /bwn cvx /rangecheck signalerror } if bits 3 1 roll bitwrite } def % Capture OFile output on the temporary file, in memory, or just as a length. /totemp { % totemp TFile fileposition OFile /OFile TFile def 3 .execn /OFile exch def TFile fileposition } bind def /tomemory { % tomemory OFile /OFile mstream def 2 .execn OFile mcontents exch /OFile exch def } bind def /tolength { % tolength OFile /OFile postream def 2 .execn OFile poslength exch /OFile exch def } bind def % Copy a range of bytes from TFile to OFile. /copyrange { % copybytes - TFile 2 index setfileposition exch sub 1024 string exch { % Stack: buf left 2 copy 1 index length .min 0 exch getinterval TFile exch readstring pop OFile exch writestring 1 index length sub dup 0 le { exit } if } loop pop pop } bind def % Pad with blanks to a specified position. /padto { % padto - OFile fileposition sub dup 0 lt { (ERROR: file position incorrect by ) print = /padto cvx /rangecheck signalerror } { { ( ) ows } repeat } ifelse } bind def % ---------------- Read objects into memory ---------------- % /touch { % touch - { { touch touch } forall } { dup xcheck { % Executable array, must be an indirect object. dup 0 get resolved? { pop pop } { oforce touch } ifelse } { { touch } forall } ifelse } { pop } ifdaelse } bind def % ---------------- Replace references with referents ---------------- % /replaceable? { % replaceable? dup type /integertype eq exch xcheck not and } bind def /replacement { % replacement dup oforce dup replaceable? { exch } if pop } bind def /replacerefs { % replacerefs { dup { 2 index 2 index undef exch replacement exch replacement 2 index 3 1 roll put } forall } { 0 1 2 index length 1 sub { 1 index exch 2 copy get replacement put } for } { } ifdaelse } bind def /replaceReferences { % - replaceReferences - Objects { replacerefs pop } lforall % Delete replaced objects. 0 1 Objects llength 1 sub { Objects 1 index lget replaceable? { PDFOPTDEBUG { (Deleting ) print dup = } if Generations 1 index 0 lput } if pop } for } bind def % ---------------- Create new objects ---------------- % /createObjects { % [...] createObjects Objects llength dup dup 3 index length add growPDFobjects % Stack: objects objn objn 3 1 roll exch { Objects 2 index 3 -1 roll lput Generations 1 index 1 lput 1 add } forall pop } bind def % ---------------- Propagate attributes ---------------- % /nopropattrs << % Never propagate these. /Type dup /Kids dup /Count dup /Parent dup % Handle Resources specially. /Resources dup >> def % Merge Resources. /mergeres { % mergeres - % Values in todict take priority over fromdict. 1 index /Resources .knownget { 1 index /Resources .knownget { % Stack: fromdict todict fromres tores exch oforce exch oforce % todict's Resources may be shared, so make a copy. dup length dict .copydict exch { % Stack: fromdict todict tores' fromkey fromvalue 2 index 2 index knownoget { % Stack: fromdict todict tores' fromkey fromvalue tovalue exch oforce exch % ProcSet is an array, other types are dictionaries. dup type /dicttype eq { % Dictionary, not ProcSet. exch dup length 2 index length add dict .copydict .copydict } { % Array or packed array, ProcSet. % Use dictionaries to do the merge. dup length 2 index length add dict begin exch { dup def } forall { dup def } forall mark currentdict end { pop } forall .packtomark } ifelse } if 2 index 3 1 roll put } forall } if /Resources exch put pop } { pop pop } ifelse } bind def % Merge attributes other than Resources. /mergeattrs { % mergeattrs % Values in todict take priority over fromdict. 1 index { % Stack: fromdict todict fromkey fromvalue //nopropattrs 2 index known { pop pop } { 2 index 2 index known { pop pop } { 2 index 3 1 roll put } ifelse } ifelse } forall } bind def % Propagate attributes to a subtree. /proppage { % proppage - % We should be able to tell when we reach a leaf % by finding a Type unequal to /Pages. Unfortunately, % some files distributed by Adobe lack the Type key % in some of the Pages nodes! Instead, we check for Kids. dup /Kids knownoget { % Accumulate inherited values. 3 1 roll % Stack: kids attrs pagesnode dup length dict .copydict mergeattrs dup 3 1 roll mergeres exch { oforce 1 index exch proppage } forall pop } { % Merge inherited values into the leaf. mergeattrs mergeres } ifelse } bind def % Propagate attributes to all pages. /propagateAttributes { % - propagateAttributes - 0 dict Trailer /Root oget /Pages oget proppage } bind def % ---------------- Identify document-level objects ---------------- % /identifyDocumentObjects { % - identifyDocumentObjects { Trailer /Root omget dup /PageMode .knownget { omvisit } if % Don't allow omvisit to trace references to Page objects. dup /OpenAction .knownget { omvisitnopage } if Trailer /Encrypt .knownget { omvisit } if dup /Threads .knownget { omforce dup //null ne { { omvisitnopage } forall } { pop } ifelse } if dup /AcroForm .knownget { omvisitnopage } if pop } visited } bind def % ---------------- Identify the objects of each page ---------------- % /identifyfont { % identifyfont - omforce { exch /FontDescriptor eq { omforce dup /Flags .knownget { 32 and 0 ne } { false } ifelse exch { exch dup dup /FontFile eq exch /FontFile2 eq or exch /FontFile3 eq or 2 index and { fontfiles exch dadd } { omvisit } ifelse } forall pop } { omvisit } ifelse } forall } bind def % Collect all the objects referenced from a page. The first object number % (which may not be the smallest one) is that of the page object itself. /identifyPageObjects { % identifyPageObjects PDFOPTDEBUG { (%Objects for page: ) print dup = } if pdffindpageref dup 0 get 3 1 roll 4 dict begin /filter_params 10 darray def /images 10 darray def /fontfiles 10 darray def { omforce % Stack: pageobj# extra page % Visit any extra objects if applicable. exch omvisitnopage % Visit Annots, if any. % We don't try to defer the drawing information. dup /Annots .knownget { omvisitnopage } if % Visit beads. dup /B .knownget { omvisitnopage } if % Visit resources dictionaries. dup /Resources .knownget { omforce dup { % Visit the first-level Resource dictionaries. omforce pop pop } forall { % Visit the resources themselves. % Skip Image XObjects, and FontFile streams if the % FontDescriptor Flags have bit 6 set. % We don't try to visit the resources in the order in which % the Contents stream(s) reference(s) them. exch dup /XObject eq { pop oforce { dup oforce /Subtype get /Image eq { dup oforce /DecodeParms .knownget { oforce { exch /JBIG2Globals eq { filter_params exch dadd } { pop } ifelse } forall } if images exch dadd } { omvisit } ifelse pop } forall } { /Font eq { oforce { identifyfont pop } forall } { oforce omvisit } ifelse } ifelse } forall } if % Visit the Contents stream(s). dup /Contents .knownget { omvisit } if % Visit Image XObjects. We don't try to visit them in % reference order. filter_params { omvisit } daforall images { omvisit } daforall % Visit FontFile streams. We don't try to visit them in % reference order. fontfiles { omvisit } daforall pop } visited end % Stack: pageobj# obj#s_larray [ 3 1 roll { 2 copy eq { pop } { exch } ifelse } lforall counttomark 1 roll ] PDFOPTDEBUG { (%Objects = ) print dup === flush } if } bind def % Identify the objects of the first page. /identifyFirstPageObjects { % - identifyFirstPageObjects Trailer /Root oget null 1 index /PageMode knownoget { /UseOutlines eq { 1 index /Outlines knownoget { exch pop } if } if } if exch pop 1 identifyPageObjects } bind def % Identify the non-shared objects of the other pages, and the shared objects. % Note that the page objects themselves may appear to be shared, because of % references from Dest entries in annotations, but they must be treated as % non-shared. Note also that some objects referenced on the first page may % also be referenced from other pages. /identifyOtherPageObjects { % - identifyOtherPageObjects [ ...] % 4 dict begin /marks lstring Objects llength lgrowto def % Collect objects of other pages and identify sharing. [ 2 1 pdfpagecount { null exch identifyPageObjects } for ] dup { { marks exch 2 copy lget 1 add 254 .min lput } forall } forall % Mark document-level and first page objects. CatalogNs { marks exch 255 lput } lforall FirstPageNs { marks exch 255 lput } forall % Mark the page objects themselves as non-shared. dup { 0 get marks exch 1 lput } forall % Collect the non-shared objects of each page. dup [ exch { [ exch { marks 1 index lget 1 ne { pop } if } forall ] } forall ] % Collect the shared objects of each page. exch [ exch { [ exch { marks 1 index lget dup 1 le exch 255 eq or { pop } if } forall ] } forall ] % Collect the shared objects. [ 1 1 marks llength 1 sub { marks 1 index lget dup 1 le exch 255 eq or { pop } if } for ] end } bind def % Identify objects not associated with any page. /identifyNonPageObjects { % - identifyNonPageObjects 4 dict begin /marks lstring Objects llength lgrowto def LPDictN marks exch 1 lput PHSN marks exch 1 lput CatalogNs { marks exch 1 lput } lforall FirstPageNs { marks exch 1 lput } forall SharedNs { marks exch 1 lput } forall OtherPageNs { { marks exch 1 lput } forall } forall %****** PUT THESE IN A REASONABLE ORDER ****** /npobj larray 0 1 1 Objects llength 1 sub { marks 1 index lget 0 eq { Generations exch lget 0 ne { 1 add } if } { pop } ifelse } for lgrowto def 0 1 1 Objects llength 1 sub { marks 1 index lget 0 eq { % i Generations 1 index lget 0 ne { % i npobj 2 index % i nobj 0 3 -1 roll % nobj 0 i lput 1 add } { pop } ifelse } { pop } ifelse } for pop npobj end } bind def % ---------------- Assign object numbers ---------------- % % Assign object numbers to all objects that will be copied. % Return the first (translated) object number in the First Page xref table. /assignObjectNumbers { % - assignObjectNumbers - OtherPageNs { { omap pop } forall } forall SharedNs { omap pop } forall NonPageNs { omap pop } lforall % Assign object numbers for the First Page xref table last. LPDictN omap % don't pop, this is the return value CatalogNs { omap pop } lforall FirstPageNs { omap pop } forall PHSN omap pop } bind def % ---------------- Create the LPDict ---------------- % % Create the contents of the LPDict. /createLPDict { % % createLPDict - LPDict dup /Linearized 1 put dup /L 4 -1 roll put % filelength dup /T 4 -1 roll put % xref0start dup /E 4 -1 roll put % firstpageend dup /H 5 -2 roll 1 index sub 2 array astore put % phsstart, end-start dup /O 1 pdffindpageref 0 get omap put /N pdfpagecount put } bind def % ---------------- Adjust object positions ---------------- % /adjustObjectPositions { % % adjustObjectPositions - % Objects fall into 4 categories: LPDict, PHS, Catalog, and others. % We handle the first two as special cases. XRef { % Stack: bdy below above key loc dup 5 index ge { 2 } { 3 } ifelse index add XRef 3 1 roll ld_put } ld_forall pop pop pop XRef LPDictN omap HeaderLength ld_put XRef PHSN omap PHSStart ld_put } bind def % ---------------- Write the output file ---------------- % % Write objects identified by object number. /writeobjn { % writeobjn - Generations 1 index lget pdfwriteobj } bind def /writeobjns { % writeobjns - { writeobjn } forall } bind def /lwriteobjns { % writeobjns - { writeobjn } lforall } bind def % Write a part of the output file. /writePart { %