diff options
Diffstat (limited to 'Master/tlpkg/tlgs/Resource/Init/pdf_main.ps')
-rw-r--r-- | Master/tlpkg/tlgs/Resource/Init/pdf_main.ps | 432 |
1 files changed, 207 insertions, 225 deletions
diff --git a/Master/tlpkg/tlgs/Resource/Init/pdf_main.ps b/Master/tlpkg/tlgs/Resource/Init/pdf_main.ps index 01af26af198..1e3fae2e589 100644 --- a/Master/tlpkg/tlgs/Resource/Init/pdf_main.ps +++ b/Master/tlpkg/tlgs/Resource/Init/pdf_main.ps @@ -30,28 +30,28 @@ pdfdict begin currentdevice //.writepdfmarkdict .getdeviceparams mark eq { //false } { pop pop //true } ifelse systemdict /DOPDFMARKS known or -} bind executeonly def +} bind def % For simplicity, we use a single interpretation dictionary for all % PDF graphics execution, even though this is too liberal. /pdfopdict mark objopdict { } forall drawopdict { } forall - /endstream { exit } bind executeonly - (%%EOF) cvn { exit } bind executeonly % for filters + /endstream { exit } bind + (%%EOF) cvn { exit } bind % for filters /obj { ( **** Error: Content stream is not terminated by 'endstream'.\n) pdfformaterror ( Output may be incorrect.\n) pdfformaterror - } bind executeonly + } bind % PDF 1.1 operators - /BX { /BXlevel BXlevel 1 add store } bind executeonly - /EX { /BXlevel BXlevel 1 sub store } bind executeonly - /PS { cvx exec } bind executeonly + /BX { /BXlevel BXlevel 1 add store } bind + /EX { /BXlevel BXlevel 1 sub store } bind + /PS { cvx exec } bind % PDF 1.2 operators /BMC { /BMClevel BMClevel 1 add store pop - } bind executeonly + } bind /BDC { /BMClevel BMClevel 1 add store exch /OC eq { @@ -69,7 +69,7 @@ pdfdict begin } { pop } ifelse - } bind executeonly + } bind /EMC { OFFlevels BMClevel 2 copy known { @@ -77,118 +77,19 @@ pdfdict begin } if 1 sub /BMClevel exch store pop - } bind executeonly + } bind /MP { pop } bind /DP { pop pop } bind /- { 0 % Bug 690016 ( **** Error: Invalid operator '-' is assumed to be the number 0.\n) pdfformaterror ( Output may be incorrect.\n) pdfformaterror - } bind executeonly + } bind /Recursive_XObject_D 1 dict def .dicttomark readonly def - -% This dictionaty encapsulates all that is needed to generate pagelabel pdfmarks. -% -% This is provided by Leon Bottou for the benefit of the djvudigital device -% which is a device developed and maintained outside of Artifex, and which is -% not a contributed device. -% -% This device does not cope with the method used by pdfwrite to pass the pagelabels -% number tree as a 'blob' of data, but requires that the page labels be passed using -% a PAGELABEL pdfmark. -% -% We don't want to do that with pdfwrite because there is no mechanism in pdfmark syntax -% to pass a tree, which means we'd have to laboriously disassemble the pdfmarks for the -% page labels and rebuild a number tree for it. This would mean pattern matching each -% string passed via PAGELABEL to see if it could be defined as a continuation -% of the preceding string, uing prefixes. Its much easier for us just to pass the tree. -% -% Note that this code simply translates the PageLabels Number tree into a number of -% individual PAGELABEL pdfmarks, if used for pdfwrite this would result in a number -% tree which consists solely of leaf nodes, where each node has a string for its label. -% This can be considerably more verbose than the shorthand possible with a Page Label -% dictionary. -% -/pagelabeldict mark - % (TEXT) .toLower (text) - /.toLower { - dup length 1 sub -1 0 { - 1 index exch 2 copy get 2#00100000 or put - } for - } bind executeonly - % int .cvAlpha (int in alphabetic base 26) - /.cvAlpha { - [ exch % construct an array of ASCII values, in reverse - { % the remainder stays on the top of stack - dup 0 eq { pop exit } if % quit if the value is zero - dup 26 mod dup 0 eq { 26 add } if % so that the division is correct - dup 64 add 3 1 roll sub 26 idiv % save the ASCII value and iterate - } loop ] - dup length dup string 3 1 roll - dup -1 1 { % put the letters in a string - 4 copy sub exch 4 -1 roll 1 sub get put - } for pop pop - } bind executeonly - % int .cvRoman (int in capital Roman numerals) - % convert a positive integer to capital Roman numerals - % return a decimal string if >= 4000 - /.cvRoman { - dup 255 string cvs % start with the decimal representation - exch 4000 lt { % convert only if Roman numerals can represent this - dup length - [ [ () (I) (II) (III) (IV) (V) (VI) (VII) (VIII) (IX) ] - [ () (X) (XX) (XXX) (XL) (L) (LX) (LXX) (LXXX) (XC) ] - [ () (C) (CC) (CCC) (CD) (D) (DC) (DCC) (DCCC) (CM) ] - [ () (M) (MM) (MMM) ] ] % Roman equivalents - () % append the Roman equivalent of each decimal digit to this string - 2 index -1 1 { - 2 index 1 index 1 sub get - 5 index 5 index 4 -1 roll sub get - 48 sub get concatstrings - } for - 4 1 roll pop pop pop - } if - } bind executeonly - % style printers - /PageStyle << - /D { 255 string cvs } bind executeonly - /R { .cvRoman } executeonly - /r { .cvRoman .toLower } executeonly - /A { .cvAlpha } executeonly - /a { .cvAlpha .toLower } executeonly >> - % check whether we want to generate pdfmarks - /wantpagelabelmarks { - % WantsPageLabels means that pagelabels will be passed - % using .pdfpagelabels and not using pdfmarks - /WantsPageLabels /GetDeviceParam .special_op - {pop pop false}{true} ifelse - } bind executeonly - % generate pagelabel pdfmark - /dopagelabel { % -- dopagelabel -- - << /S null /P () /O 0 >> begin - wantpagelabelmarks { - Trailer /Root knownoget { - oforce /PageLabels knownoget { - oforce Page# 1 sub - numogetle - { oforce - dup /S knownoget not { //false } if /S exch def - dup /P knownoget not { 0 string } if /P exch def - /St knownoget not { 1 } if exch sub /O exch def - } if - P Page# 1 sub O add PageStyle S knownoget { exec concatstrings } if - mark /Label 3 -1 roll /PAGELABEL pdfmark - } if - } if - } if - end - } bind executeonly -.dicttomark readonly def - % ======================== Main program ======================== % end % pdfdict @@ -298,7 +199,7 @@ currentdict /runpdfstring .undef pdfdict begin pdfopen begin /CumulativePageCount currentpagedevice /PageCount get def -} bind executeonly def +} bind def /runpdfpagerange { % - runpdfpagerange <firstpage#> <lastpage#> <</DisablePageHandler true>> setpagedevice @@ -485,7 +386,7 @@ currentdict /runpdfstring .undef } ifelse } ifelse }ifelse -} bind executeonly def +} bind def /dopdfpages { % firstpage# lastpage# dopdfpages - << /PDFScanRules //true >> setuserparams % set scanning rules for PDF vs. PS @@ -511,7 +412,7 @@ currentdict /runpdfstring .undef % imaged is a PS file. currentpagedevice /PageSpotColors known { << /PageSpotColors -1 >> setpagedevice } if << /PDFScanRules //null >> setuserparams % restore scanning rules for PS -} bind executeonly def +} bind def /runpdfend { RepairedAnError @@ -527,7 +428,7 @@ currentdict /runpdfstring .undef PDFTopSave restore end % userdict 2 vmreclaim % couldn't hurt -} bind executeonly def +} bind def % Copy stream to an external temporary file and % return the file name as PS name. @@ -558,7 +459,7 @@ currentdict /runpdfstring .undef } { closefile } ifelse -} bind executeonly def +} bind def % Recursively enumerate /Names entries % <node> pdf_collection_names /temp_file_name ... @@ -587,7 +488,7 @@ currentdict /runpdfstring .undef } forall } if } ifelse -} bind executeonly def +} bind def % Copy selected subfiles to temporary files and return the file names % as a PostScript names to protect them from restore. @@ -607,7 +508,7 @@ currentdict /runpdfstring .undef pop } ifelse } if -} bind executeonly def +} bind def /runpdf { % <file> runpdf - %% Get the PDF filename (it *must* be a file even if it came from stdin it gets @@ -650,7 +551,7 @@ currentdict /runpdfstring .undef } forall pop } ifelse -} bind executeonly def +} bind def currentdict /pdf_collection_files .undef @@ -659,7 +560,7 @@ end % systemdict % It is OK to use { (%stdin) run } here, because a startjob cannot occur. /.runstdin { { (%stdin) run } execute0 -} bind executeonly def +} bind def end % userdict pdfdict begin @@ -676,14 +577,14 @@ pdfdict begin % they are invalid, the PDF file is probably unreadable anyway. /traileropdict mark - (<<) cvn { /dictlevelcount dictlevelcount 1 add store mark } bind executeonly + (<<) cvn { /dictlevelcount dictlevelcount 1 add store mark } bind (>>) cvn { { .dicttomark } stopped { ( **** Warning: File has unbalanced >> in trailer.\n) pdfformatwarning } if /dictlevelcount dictlevelcount 1 sub def dictlevelcount 0 eq { exit } if - } bind executeonly - ([) cvn { mark } bind executeonly % ditto + } bind + ([) cvn { mark } bind % ditto (]) cvn dup load % /true true % see .pdfexectoken in pdf_base.ps % /false false % ibid. @@ -695,7 +596,7 @@ pdfdict begin ( **** Error: indirect object reference \(R\) encountered with invalid arguments.) pdfformaterror ( Output may be incorrect.\n) pdfformaterror } ifelse - } bind executeonly % see Objects below + } bind % see Objects below .dicttomark readonly def % After reading entry count: skip whitespace, exit on a digit @@ -876,22 +777,22 @@ pdfdict begin pdfformatwarning } if PDFfile traileropdict .pdfrun - } bind executeonly def + } bind def currentdict /xref-char-dict undef % This dicitonary is used to read the xref dictionary. It should work for % reading any dictionary. dictlevelcount must contain 0. /xrefopdict mark - (<<) cvn { /dictlevelcount dictlevelcount 1 add def mark } bind executeonly + (<<) cvn { /dictlevelcount dictlevelcount 1 add def mark } bind (>>) cvn { .dicttomark /dictlevelcount dictlevelcount 1 sub def - dictlevelcount 0 eq { exit} if } bind executeonly - ([) cvn { mark } bind executeonly % ditto + dictlevelcount 0 eq { exit} if } bind + ([) cvn { mark } bind % ditto (]) cvn dup load % /true true % see .pdfexectoken in pdf_base.ps % /false false % ibid. % /null null % ibid. - /R { /resolveR cvx 3 packedarray cvx } bind executeonly % see Objects below + /R { /resolveR cvx 3 packedarray cvx } bind % see Objects below .dicttomark readonly def % Get a variable length positive integer value from a stream. A value @@ -899,7 +800,7 @@ currentdict /xref-char-dict undef /getintn { % <stream> <count> getintn int 0 exch { 256 mul 1 index read pop add } repeat exch pop % Discard stream -} bind executeonly def +} bind def % This array contains handlers for processing the different types of % entries in the XRef stream. @@ -912,7 +813,7 @@ currentdict /xref-char-dict undef % (obj num: ) print 2 index pdfstring cvs print ( ) print % (loc: ) print 1 index pdfstring cvs print ( ) print % (gen: ) print dup === flush - } bind executeonly % Do nothing for free xref entries + } bind % Do nothing for free xref entries % XRef entry type 1 - normal or n type xref entry { % field 2 = obj loc, field 3 = gen num % (normal ) print @@ -922,7 +823,7 @@ currentdict /xref-char-dict undef 0 3 1 roll % set stream number = 0 //false setxrefentry 3 -1 roll pop % remove stream number - } bind executeonly + } bind % XRef entry type 2 - compressed object type xref entry { % field 2 = object stream num, field 3 = index into object stream % (Compressed objects: ) print @@ -930,7 +831,7 @@ currentdict /xref-char-dict undef % (field 2: ) print 1 index pdfstring cvs print ( ) print % (field 3: ) print dup === flush 0 //false setxrefentry pop % set generation number = 0 - } bind executeonly + } bind ] def % Read the PDF 1.5 version of the xref table. @@ -1012,7 +913,7 @@ currentdict /xref-char-dict undef pop % Remove Index array pair loc } for % Loop through Index array entries pop pop % Remove Index array and xref stream - } bind executeonly def + } bind def % Read the cross-reference table. % <pos> is the position either from the startxref statement or the /Prev @@ -1066,7 +967,7 @@ currentdict /xref-char-dict undef } { readpdf15xref } % otherwise assume PDF 1.5 xref stream ifelse - } bind executeonly def + } bind def % Open a PDF file and read the header, trailer, and cross-reference. /pdfopen { % <file> pdfopen <dict> @@ -1096,7 +997,7 @@ currentdict /xref-char-dict undef pdfopenfile begin pdfopencache currentdict end -} bind executeonly def +} bind def /process_trailer_attrs { % - process_trailer_attrs - writeoutputintents @@ -1315,7 +1216,7 @@ currentdict /xref-char-dict undef } ifelse } if } if -} bind executeonly def +} bind def % Verify that each entry in the xref table is pointing at an object with % the correct object number and generation number. @@ -1377,7 +1278,7 @@ currentdict /xref-char-dict undef /PageCount pdfpagecount def /PageNumbers PageCount 65534 .min dict def /PageIndex PageCount 65534 .min array def -} bind executeonly def +} bind def /pdfopenfile { % <file> pdfopenfile <dict> pdfdict readonly pop % can't do it any earlier than this @@ -1540,7 +1441,7 @@ currentdict /xref-char-dict undef verify_page_tree currentdict end - } bind executeonly def + } bind def %% Executing token on a file will close the file if we reach EOF while %% processing. When repairing broken files (or searching for startxref @@ -1567,7 +1468,7 @@ currentdict /xref-char-dict undef } { token } ifelse -} bind executeonly def +} bind def % Look for the last (startxref) from the current position % of the file. Return the position after (startxref) if found or -1 . @@ -1577,7 +1478,7 @@ currentdict /xref-char-dict undef bytesavailable 9 lt { exit } if pop dup fileposition } loop -} bind executeonly def +} bind def % Search for the last 'startxfer' and read a following token, which % must be a number. Don't pay any attention to %%EOF because it's @@ -1609,30 +1510,30 @@ currentdict /xref-char-dict undef ( Output may be incorrect.\n) pdfformaterror /findxref cvx /syntaxerror signalerror } if -} bind executeonly def +} bind def /stderrfile (%stderr) (w) file def /stdoutfile (%stdout) (w) file def /stderrprint { % <string> stderrprint - //stderrfile dup 3 -1 roll writestring flushfile -} bind executeonly def +} bind def /stdoutprint { % <string> stderrprint - //stdoutfile dup 3 -1 roll writestring flushfile -} bind executeonly def +} bind def /pdfformaterror { % <string> pdfformaterror - stdoutprint /Repaired //true store /RepairedAnError //true store -} bind executeonly def +} bind def /pdfformatwarning { % <string> pdfformaterror - QUIET not {stdoutprint}{pop}ifelse /Repaired //true store PDFSTOPONWARNING {/warning cvx /undefined signalerror} if -} bind executeonly def +} bind def /knownoget_safe { 2 copy knownoget { 3 1 roll pop pop //true } { pop pop //false } ifelse @@ -1658,7 +1559,7 @@ currentdict /xref-char-dict undef stderrprint ( <<<<\n) stderrprint } ifelse -} bind executeonly def +} bind def % The UndefProcList collects noisy warnings. % This gets rid of many multiple warnings from pdf_font.ps /printCollectedWarnings { @@ -1670,7 +1571,7 @@ currentdict /xref-char-dict undef } forall (\n) stderrprint } if -} bind executeonly def +} bind def /printrepaired { QUIET not @@ -1686,7 +1587,7 @@ currentdict /xref-char-dict undef ( **** specification.\n\n) stdoutprint } if -} bind executeonly def +} bind def /printrepairederror { QUIET not @@ -1695,7 +1596,7 @@ currentdict /xref-char-dict undef ( **** The rendered output from this file may be incorrect.\n) stdoutprint } if -} bind executeonly def +} bind def % Write the outline structure for a file. Uses linkdest (below). % omit links to pages that don't exist. @@ -1776,14 +1677,14 @@ currentdict /xref-char-dict undef /First knownoget { { dup writeoutline /Next knownoget not { exit } if } loop } if - } bind executeonly def + } bind def % Close a PDF file. /pdfclose % <dict> pdfclose - { begin PDFfile closefile end - } bind executeonly def + } bind def % ======================== Page accessing ======================== % @@ -1829,7 +1730,7 @@ currentdict /xref-char-dict undef ifelse } ifelse - } bind executeonly def + } bind def /obj_get { LocalResources 1 index knownoget { @@ -1853,7 +1754,7 @@ currentdict /xref-char-dict undef pop pop pop 0 }ifelse }ifelse -}bind executeonly def +}bind def % Get the value of a resource on a given page. /rget { % <resname> <pagedict> <restype> rget <value> -true- @@ -1889,7 +1790,7 @@ currentdict /xref-char-dict undef pop pop pop pop } ifelse } ifelse -} bind executeonly def +} bind def % Get the total number of pages in the document. /pdfpagecount % - pdfpagecount <int> @@ -1934,7 +1835,7 @@ currentdict /xref-char-dict undef }{ 0 } ifelse - } bind executeonly def + } bind def % Check for loops in the 'page tree' but accept an acyclic graph. % - verify_page_tree - @@ -1963,7 +1864,7 @@ currentdict /xref-char-dict undef end } if } if -} bind executeonly def +} bind def /pdffindpage? { % <int> pdffindpage? 1 null (page not found) % <int> pdffindpage? 1 noderef (page found) @@ -1985,7 +1886,7 @@ currentdict /xref-char-dict undef % Stack: index null|noderef dup //null eq { pop pop 1 //null exit } if } loop -} bind executeonly def +} bind def % Find the N'th page of the document by iterating through the Pages tree. % The first page is numbered 1. @@ -2000,10 +1901,10 @@ currentdict /xref-char-dict undef { pop pop pop } % don't store more than 65534 pagenumbers ifelse exch pop -} bind executeonly def +} bind def /pdffindpage { % <int> pdffindpage <pagedict> pdffindpageref oforce -} bind executeonly def +} bind def % Find the N'th page of the document. % The first page is numbered 1. @@ -2016,7 +1917,7 @@ currentdict /xref-char-dict undef { exch pop oforce } { pop pdffindpage } ifelse - } bind executeonly def + } bind def % Find the page number of a page object (inverse of pdfgetpage). /pdfpagenumber % <pagedict> pdfpagenumber <int> @@ -2030,7 +1931,7 @@ currentdict /xref-char-dict undef for exch pop } ifelse - } bind executeonly def + } bind def % Arrange the four elements that define a rectangle into a 'normal' order. /normrect_elems % <x1> <y1> <x2> <y2> normrect_elems <llx> <lly> <urx> <ury> @@ -2048,14 +1949,14 @@ currentdict /xref-char-dict undef 2 copy gt { exch } if % <x2> <x1> <lly> <ury> 4 2 roll 2 copy lt { exch } if % <lly> <ury> <urx> <llx> 4 1 roll exch % <llx> <lly> <urx> <ury> -} bind executeonly def +} bind def % Arrange a rectangle into a 'normal' order. I.e the lower left corner % followed by the upper right corner. /normrect % <rect> normrect <rect> { aload pop normrect_elems 4 array astore -} bind executeonly def +} bind def /fix_empty_rect_elems % </Name> <x1> <y1> <x2> <y2> fix_empty_rect_elems <x1> <y1> <x2'> <y2'> { dup 3 index eq { //true } { 1 index 4 index eq } ifelse { @@ -2067,11 +1968,11 @@ currentdict /xref-char-dict undef } { 5 -1 roll pop } ifelse -} bind executeonly def +} bind def /boxrect % <llx> <lly> <urx> <ury> boxrect <x> <y> <w> <h> { exch 3 index sub exch 2 index sub - } bind executeonly def + } bind def /resolvedest { % <name|string|other> resolvedest <other|null> dup type /nametype eq { Trailer /Root oget /Dests knownoget { @@ -2092,12 +1993,12 @@ currentdict /xref-char-dict undef } ifelse } if } ifelse -} bind executeonly def +} bind def % Procedures to do the necessary transformations of view destinations % <PDF2PS_matrix> <rot> <view> -- <view'> /viewdestprocs 8 dict dup begin - /Fit { exch pop exch pop } bind executeonly def + /Fit { exch pop exch pop } bind def /FitH { aload length 2 lt { 1 array astore @@ -2107,7 +2008,7 @@ currentdict /xref-char-dict undef 4 -1 roll transform exch pop 2 array astore } ifelse - } bind executeonly def + } bind def /FitV { aload length 2 lt { 1 array astore @@ -2117,7 +2018,7 @@ currentdict /xref-char-dict undef 4 -1 roll transform pop 2 array astore } ifelse - } bind executeonly def + } bind def /FitB /Fit load def /FitBH /FitH load def /FitBV /FitV load def @@ -2150,14 +2051,14 @@ currentdict /xref-char-dict undef 2 { 3 -1 roll //null eq { pop //null } if exch } repeat % put the nulls back 3 -1 roll 4 array astore - } bind executeonly def + } bind def /FitR { exch pop aload pop 2 { 5 index transform 4 2 roll } repeat normrect_elems 5 array astore exch pop - } bind executeonly def + } bind def end readonly def /linkdest { % <link|outline> linkdest @@ -2208,31 +2109,102 @@ end readonly def ifelse } if -} bind executeonly def - - -%% Used to recursively check dictionaries for any /.gs.pdfobj# keys -%% and remove them if so -%% -any- /Removepdfobj# -any- - -/Removepdfobj# -{ - dup type /dicttype eq { - dup /.gs.pdfobj# known { - dup /.gs.pdfobj# undef - } if - dup {Removepdfobj# 2 index 3 1 roll put} forall - } if -}bind executeonly def - +} bind def % <pagedict> mark ... -proc- <page#> <error> /namedactions 8 dict dup begin - /FirstPage { 1 /CumulativePageCount where {pop CumulativePageCount}{0}ifelse add //false } bind executeonly def - /LastPage { pdfpagecount /CumulativePageCount where {pop CumulativePageCount}{0}ifelse add //false } bind executeonly def - /NextPage { counttomark 2 add index pdfpagenumber 1 add dup pdfpagecount gt exch /CumulativePageCount where {pop CumulativePageCount}{0}ifelse add exch} bind executeonly def - /PrevPage { counttomark 2 add index pdfpagenumber 1 sub dup 1 lt exch /CumulativePageCount where {pop CumulativePageCount}{0}ifelse add exch} bind executeonly def + /FirstPage { 1 /CumulativePageCount where {pop CumulativePageCount}{0}ifelse add //false } def + /LastPage { pdfpagecount /CumulativePageCount where {pop CumulativePageCount}{0}ifelse add //false } def + /NextPage { counttomark 2 add index pdfpagenumber 1 add dup pdfpagecount gt exch /CumulativePageCount where {pop CumulativePageCount}{0}ifelse add exch} bind def + /PrevPage { counttomark 2 add index pdfpagenumber 1 sub dup 1 lt exch /CumulativePageCount where {pop CumulativePageCount}{0}ifelse add exch} bind def end readonly def % <pagedict> <annotdict> -proc- - +/annottypes 5 dict dup begin + /Text { + mark exch + { /Rect /Open /Contents /F} + { 2 copy knownoget { 3 -1 roll } { pop } ifelse } + forall pop {/ANN pdfmark} stopped {cleartomark} if + } bind def + /Link { + /NO_PDFMARK_DESTS where {pop NO_PDFMARK_DESTS not}{true}ifelse + { + mark exch + dup /BS knownoget { << exch { oforce } forall >> /BS exch 3 -1 roll } if + dup /F knownoget { /F exch 3 -1 roll } if + dup /C knownoget { /Color exch 3 -1 roll } if + dup /Rect knownoget { /Rect exch 3 -1 roll } if + dup /Border knownoget { + dup type /arraytype eq { + dup length 3 lt + } { + //true + } ifelse { + pop [ 0 0 0 ] % Following AR5 use invisible border. + } if + /Border exch 3 -1 roll + } if + dup /A knownoget { + dup /URI known { + /A mark 3 2 roll % <<>> /A [ <<action>> + { oforce } forall + .dicttomark + 3 2 roll + } { + dup /S knownoget { + %% Because we process GoTo Destinations into absolute references in the PDF file + %% we need to resolve the /D or /Dest. However, we must *not* do this for + %% GoToR Destinations because (obviously) those are in a different file and + %% we cannot resolve them into absolute references. We don't need to anyway + %% because that file must already have a named destination. + dup /GoTo eq { + pop + dup /D knownoget { + exch pop exch dup length dict copy dup /Dest 4 -1 roll put + } if + }{ + dup /GoToR eq { + pop /A mark % <<..action dict..>> /A [ + 3 2 roll % /A [ <<..action dict..>> + { oforce } forall + .dicttomark + 3 2 roll + }{ + dup /Launch eq { + pop /A mark % <<..action dict..>> /A [ + 3 2 roll % /A [ <<..action dict..>> + { oforce } forall + .dicttomark + 3 2 roll + }{ + /Named eq { + /N knownoget { + namedactions exch .knownget { + exec { + pop + ( **** Warning: Ignoring a named action pointing out of the document page range.\n) + pdfformatwarning + } { + /Page exch 3 -1 roll + } ifelse + } if + } if + } if + }ifelse + } ifelse + } ifelse + } if + } ifelse + } if + { linkdest } stopped { + cleartomark + ( **** Warning: Link annotation points out of the document page range.\n) + pdfformatwarning + } { + pop {/LNK pdfmark} stopped {cleartomark} if + } ifelse + }{pop} ifelse + } bind def +end readonly def % **** The following procedure should not be changed to allow clients % **** to directly interface with the constituent procedures. GSview @@ -2244,14 +2216,14 @@ end readonly def pdfshowpage_init % <pagedict> pdfshowpage_setpage % <pagedict> pdfshowpage_finish % - - } bind executeonly def + } bind def /pdfpagecontents % <pagedict> pdfpagecontents <contents> - { } bind executeonly def + { } bind def /pdfshowpage_init % <pagedict> pdfshowpage_init <pagedict> { /DSCPageCount DSCPageCount 1 add store - } bind executeonly def + } bind def /get_media_box { % <pagedict> get_media_box <box> <bool> /MediaBox pget { @@ -2262,7 +2234,7 @@ end readonly def ( Output may be incorrect.\n) pdfformaterror [ 0 0 currentpagedevice /PageSize get aload pop ] //false } ifelse -} bind executeonly def +} bind def /get_any_box { % <pagedict> get_any_box <box name> <box> //systemdict /UseBleedBox .knownget dup { and } if { @@ -2353,7 +2325,7 @@ end readonly def } ifelse 4 array astore % /SomeBox [mX0 mY0 mX1 mY1] } ifelse -} bind executeonly def +} bind def % Compute the matrix that transforms the PDF->PS "default" user space /pdf_PDF2PS_matrix { % <pdfpagedict> -- matrix @@ -2433,7 +2405,7 @@ end readonly def % stack: savedCTM <pdfpagedict> pop matrix currentmatrix exch setmatrix -} bind executeonly def +} bind def % Cache the matrix that transforms the PDF->PS "default" user space % into <pdfpagedict> under the key //PDF2PS_matrix_key, then return it @@ -2445,13 +2417,13 @@ end readonly def dup dup pdf_PDF2PS_matrix //PDF2PS_matrix_key exch put //PDF2PS_matrix_key get } ifelse -} bind executeonly def +} bind def currentdict /PDF2PS_matrix_key undef /.pdfshowpage_Install { % <pagedict> [<prevproc>] .pdfshowpage_Install - 0 get exec pdf_cached_PDF2PS_matrix concat -} bind executeonly def +} bind def /pdfshowpage_setpage { % <pagedict> pdfshowpage_setpage <pagedict> 6 dict begin % for setpagedevice @@ -2552,7 +2524,7 @@ currentdict /PDF2PS_matrix_key undef /Install exch def % Stack: pagedict currentpagedict pop currentdict end setpagedevice -} bind executeonly def +} bind def /.free_page_resources { % - .free_page_resources - Page /Resources pget { @@ -2566,7 +2538,7 @@ currentdict /PDF2PS_matrix_key undef } forall } if } if -} bind executeonly def +} bind def /pdfshowpage_finish { % <pagedict> pdfshowpage_finish - save /PDFSave exch store @@ -2579,9 +2551,6 @@ currentdict /PDF2PS_matrix_key undef .writepdfmarks { - % Pagelabel - pagelabeldict begin dopagelabel end - % Copy the boxes. % Copy the boxes. { /CropBox /BleedBox /TrimBox /ArtBox } { 2 copy pget { @@ -2594,6 +2563,20 @@ currentdict /PDF2PS_matrix_key undef pop } ifelse } forall + + % Copy annotations and links. + dup /Annots knownoget { + 0 1 2 index length 1 sub + { 1 index exch oget + dup type /dicttype eq { + dup /Subtype oget annottypes exch .knownget { exec } { pop } ifelse + } { + pop + } ifelse + } + for pop + } if + } if % end .writepdfmarks % Display the actual page contents. @@ -2705,7 +2688,7 @@ currentdict /PDF2PS_matrix_key undef .setglobal /RepairedAnError exch def /Repaired exch def -} bind executeonly def +} bind def % Display the contents of a page (including annotations). /showpagecontents { % <pagedict> showpagecontents - @@ -2763,7 +2746,7 @@ currentdict /PDF2PS_matrix_key undef //systemdict /ShowAcroForm .knownget { //true eq } { //false } ifelse { Trailer /Root oget /AcroForm knownoget { draw_acro_form } if } if -} bind executeonly def +} bind def /processcolorspace { % - processcolorspace <colorspace> % The following is per the PLRM3. @@ -2771,7 +2754,7 @@ currentdict /PDF2PS_matrix_key undef exch pop exch pop dup type /nametype ne { cvn } if dup { setcolorspace } .internalstopped { pop /DeviceRGB } if -} bind executeonly def +} bind def % ------ Transparency support ------ % @@ -2812,7 +2795,7 @@ currentdict /PDF2PS_matrix_key undef % Also check for transparency in the annotation (if not in resources). { pop //true } { annotsusetransparency } ifelse } ifelse -} bind executeonly def +} bind def % Check if transparency is specified in an ExtGState dict /extgstateusestransparency { % <gstate dict> extgstateusestransparency <bool> @@ -2830,7 +2813,7 @@ currentdict /PDF2PS_matrix_key undef pop exit } loop } ifelse -} bind executeonly def +} bind def % Check if transparency is used in a Pattern /patternusestransparency { % <Pattern dict> patternusestransparency <bool> @@ -2844,7 +2827,7 @@ currentdict /PDF2PS_matrix_key undef } loop } ifelse -} bind executeonly def +} bind def % Check the Resources of a page or Form. Check for loops in the resource chain. /resourceusestransparency { % <dict> <dict> resourceusestransparency <bool> @@ -2912,7 +2895,7 @@ currentdict /PDF2PS_matrix_key undef pop //false exit } loop exch pop -} bind executeonly def +} bind def % Check if the annotations on a page use transparency /annotsusetransparency { % <page dict> annotsusetransparency <bool> @@ -2949,14 +2932,14 @@ currentdict /PDF2PS_matrix_key undef } ifelse } forall % For all annots on the page } if -} bind executeonly def +} bind def % Add a color name to our spot color list. Ignore /All and /None /putspotcolor { % <name> <spotcolordict> putspotcolor - % The 'name' could be a string. If so then convert to a name. exch dup type /stringtype eq { cvn } if dup dup /None eq exch /All eq or { pop pop } { 0 put } ifelse -} bind executeonly def +} bind def % Determine which spot colors are used within a color space Note: This % dict will include all colors used in Separation or DeviceN color spaces. @@ -2981,7 +2964,7 @@ currentdict /PDF2PS_matrix_key undef } ifelse } if pop pop -} bind executeonly def +} bind def % Check the Resources of a page, form, or annotation. Determine which spot % colors are used within the resource Note: The spot color dict will include @@ -3056,7 +3039,7 @@ currentdict /PDF2PS_matrix_key undef } if exit } loop -} bind executeonly def +} bind def % Determine which spot colors are used within the annotations. Note: This % dict will include all colors used in Separation or DeviceN color spaces. @@ -3075,7 +3058,7 @@ currentdict /PDF2PS_matrix_key undef pop } ifelse } forall -} bind executeonly def +} bind def % Determine spot colors are used within a page. We are creating a dict to % hold the spot color names as keys. Using a dict avoids having to worry @@ -3110,7 +3093,7 @@ currentdict /PDF2PS_matrix_key undef 3 -1 roll /Annots knownoget { annotsspotcolors } if pop % Discard reference loop dict -} bind executeonly def +} bind def % Determine how many (if any) spot colors are used by a page. % Note: This count does not include Cyan, Magenta, Yellow, or Black @@ -3121,7 +3104,7 @@ currentdict /PDF2PS_matrix_key undef [ /Cyan /Magenta /Yellow /Black ] { 2 index exch known { 1 sub } if } forall exch pop % Remove spot color dict -} bind executeonly def +} bind def % ------ ColorSpace substitution support ------ % @@ -3151,7 +3134,7 @@ currentdict /PDF2PS_matrix_key undef } ifelse } if } if -} bind executeonly def +} bind def %% <loopdict> <Objectdict> <calling obj_num> pdfform_detect_cspacesub <boolean> %% @@ -3235,7 +3218,7 @@ currentdict /PDF2PS_matrix_key undef } loop %% remove and discard the loopdict exch pop -} bind executeonly def +} bind def % % <pagedict> pdfshowpage_detect_cspacesub <pagedict> <boolean> @@ -3253,7 +3236,7 @@ currentdict /PDF2PS_matrix_key undef /HighLevelDevice /GetDeviceParam .special_op { exch pop not exch pop }if -} bind executeonly def +} bind def % % <pagedict> pdfshowpage_setcspacesub <pagedict> @@ -3326,7 +3309,7 @@ currentdict /PDF2PS_matrix_key undef pop } ifelse } if -} bind executeonly def +} bind def % Write OutputIntents to device if the device handles it /writeoutputintents { @@ -3387,7 +3370,7 @@ currentdict /PDF2PS_matrix_key undef pop pop } if } if -} bind executeonly def +} bind def end % pdfdict .setglobal @@ -3410,7 +3393,6 @@ DELAYBIND not { /.setfillconstantalpha /.setalphaisshape /.currentalphaisshape /.settextspacing /.currenttextspacing /.settextleading /.currenttextleading /.settextrise /.currenttextrise /.setwordspacing /.currentwordspacing /.settexthscaling /.currenttexthscaling -/.setdistillerparams % Used by our own test suite files %/.pushpdf14devicefilter % transparency-example.ps |