| 1 |
%!PS-Adobe-2.0 Resource |
| 2 |
% |
| 3 |
% This is the set of procedures that are necessary for using dvips with the |
| 4 |
% -z flag to create PDF-ready PostScript from HyperTeX. |
| 5 |
% Written by Tanmoy Bhattacharya and Mark D. Doyle 11/94. |
| 6 |
% It is (C) Copyright 1994 by Tanmoy Bhattacharya, Mark D. Doyle |
| 7 |
% and the University of California. You may modify and use this program to |
| 8 |
% your heart's content. |
| 9 |
% |
| 10 |
% Version number info |
| 11 |
% 1 0 Probably first release |
| 12 |
% 1 1 Added external handler to let ghostview work |
| 13 |
% 1 2 Attempt at using weblink plugin (not checked) |
| 14 |
% |
| 15 |
% 2 0 Complete rewrite. |
| 16 |
% 2 1 skipped (because testing remotely: it is a debugging version) |
| 17 |
% 2 2 Hopefully correct. |
| 18 |
% 2 3 weblink with anchors corrected. |
| 19 |
% 2 4 bug fix: cvn for dest added |
| 20 |
% 2 5 bug fix: No point of error message if not on a distiller. |
| 21 |
% 2 6 bug fix: stupid {..} error. Check destination name to avoid bad names. |
| 22 |
% 2 2 tested under (Being tested :-) |
| 23 |
% unix distiller (old) |
| 24 |
% mac 2.1 |
| 25 |
% mac 2.0 |
| 26 |
% windows 2.0 |
| 27 |
% ghostscript |
| 28 |
|
| 29 |
%%BeginResource: procset hps.lpro 2 6 |
| 30 |
/HPSdict 20 dict dup begin |
| 31 |
|
| 32 |
/braindeaddistill 50 def |
| 33 |
|
| 34 |
/rfch % remove first charcter of string |
| 35 |
{dup length 1 sub 1 exch getinterval} bind def |
| 36 |
|
| 37 |
/splituri % string splituri dest uri/file true_if_uri |
| 38 |
{dup (#) search |
| 39 |
{exch pop} |
| 40 |
{() exch} |
| 41 |
ifelse |
| 42 |
dup (file:) anchorsearch |
| 43 |
{pop exch pop 3 -1 roll pop false} |
| 44 |
{pop 3 -1 roll exch pop true} |
| 45 |
ifelse} bind def |
| 46 |
|
| 47 |
/lookuptarget |
| 48 |
{exch rfch dup % drop the hashmark |
| 49 |
/TargetAnchors where |
| 50 |
{pop TargetAnchors dup |
| 51 |
3 -1 roll known |
| 52 |
{exch get true} |
| 53 |
{pop (target unknown:)print == false} |
| 54 |
ifelse} |
| 55 |
{pop pop |
| 56 |
(target dictionary unknown\012)print false} |
| 57 |
ifelse} |
| 58 |
bind def |
| 59 |
|
| 60 |
/savecount 0 def |
| 61 |
|
| 62 |
/stackstopped % Like stopped, but clear to current mark on error |
| 63 |
{ count counttomark sub /savecount exch store |
| 64 |
stopped |
| 65 |
count savecount sub 1 sub dup 0 gt |
| 66 |
{{exch pop} repeat} |
| 67 |
{pop} |
| 68 |
ifelse |
| 69 |
} |
| 70 |
bind def |
| 71 |
|
| 72 |
% PDF implementation limit for names is 127, see PDF specification, |
| 73 |
% version 1.6, appendix C "Implementation Limits, |
| 74 |
% table C.1 "Architectural limits", page 920. |
| 75 |
/tempstring 128 string def |
| 76 |
|
| 77 |
/targetvalidate |
| 78 |
{1 index dup length 127 gt exch |
| 79 |
tempstring cvs |
| 80 |
dup (/) search |
| 81 |
{pop pop pop exch pop true exch} |
| 82 |
{pop} |
| 83 |
ifelse |
| 84 |
token {pop length 0 ne} {true} ifelse or |
| 85 |
not} bind def |
| 86 |
|
| 87 |
/targetdump-hook where |
| 88 |
{pop} |
| 89 |
{/targetdump-hook |
| 90 |
{dup mark exch gsave initmat setmatrix |
| 91 |
{{ mark /Dest 4 2 roll |
| 92 |
targetvalidate |
| 93 |
{aload pop exch pop |
| 94 |
/Page 3 1 roll /View exch [ exch /FitH exch ] |
| 95 |
/DEST pdfmark} |
| 96 |
{cleartomark} |
| 97 |
ifelse} forall} stackstopped pop |
| 98 |
grestore} bind def } |
| 99 |
ifelse |
| 100 |
|
| 101 |
/baseurl |
| 102 |
{mark exch 1 dict dup 3 -1 roll |
| 103 |
/Base exch put |
| 104 |
/URI exch |
| 105 |
/DOCVIEW {pdfmark} stackstopped pop} |
| 106 |
bind def |
| 107 |
|
| 108 |
/externalhack systemdict /PDF known def |
| 109 |
/oldstyle true def |
| 110 |
|
| 111 |
/initmat matrix currentmatrix def |
| 112 |
/actiondict 2 dict dup /Subtype /URI put def |
| 113 |
/weblinkhandler |
| 114 |
{ dup 3 1 roll mark 4 1 roll |
| 115 |
/Title 4 1 roll |
| 116 |
splituri 3 -1 roll |
| 117 |
dup length 0 gt |
| 118 |
{cvn /Dest exch 4 2 roll} |
| 119 |
{pop} |
| 120 |
ifelse |
| 121 |
{externalhack |
| 122 |
{/HTTPFile exch} |
| 123 |
{actiondict dup 3 -1 roll /URI exch put |
| 124 |
/Action exch} |
| 125 |
ifelse} |
| 126 |
{externalhack |
| 127 |
{/HTTPFile exch} |
| 128 |
{/File exch /Action /GoToR} |
| 129 |
ifelse |
| 130 |
} |
| 131 |
ifelse |
| 132 |
counttomark 2 sub -1 roll |
| 133 |
aload pop |
| 134 |
/Rect 4 1 roll |
| 135 |
/Border 3 1 roll |
| 136 |
/Color exch |
| 137 |
oldstyle |
| 138 |
{/LNK} |
| 139 |
{/Subtype /Link /ANN} |
| 140 |
ifelse |
| 141 |
gsave initmat setmatrix |
| 142 |
{pdfmark} stackstopped |
| 143 |
grestore} |
| 144 |
bind def |
| 145 |
|
| 146 |
/externalhandler where |
| 147 |
{pop} |
| 148 |
{/externalhandler |
| 149 |
{ 2 copy |
| 150 |
{weblinkhandler} exec |
| 151 |
{/externalhack externalhack not store |
| 152 |
2 copy |
| 153 |
{weblinkhandler} exec |
| 154 |
{/externalhack externalhack not store |
| 155 |
/oldstyle false store |
| 156 |
2 copy |
| 157 |
{weblinkhandler} exec |
| 158 |
{(WARNING: external refs disabled\012)print |
| 159 |
/externalhandler {pop pop} bind store externalhandler} |
| 160 |
{pop pop} |
| 161 |
ifelse} |
| 162 |
{pop pop /externalhack externalhack not store} |
| 163 |
ifelse} |
| 164 |
{pop pop /externalhandler {weblinkhandler pop} bind store} |
| 165 |
ifelse} |
| 166 |
bind def} |
| 167 |
ifelse |
| 168 |
|
| 169 |
/pdfmnew |
| 170 |
{dup type /stringtype eq {externalhandler} { |
| 171 |
exch dup rfch exch 3 -1 roll |
| 172 |
lookuptarget |
| 173 |
{mark 4 1 roll |
| 174 |
/Title 4 1 roll |
| 175 |
aload pop |
| 176 |
exch |
| 177 |
pop |
| 178 |
/Page 3 1 roll |
| 179 |
/View exch |
| 180 |
[ exch /FitH exch ] |
| 181 |
5 -1 roll |
| 182 |
aload pop |
| 183 |
/Rect 4 1 roll |
| 184 |
/Border 3 1 roll |
| 185 |
/Color exch |
| 186 |
/LNK gsave initmat setmatrix pdfmark grestore} |
| 187 |
{pop pop} |
| 188 |
ifelse} ifelse} |
| 189 |
bind def |
| 190 |
|
| 191 |
/pdfmold |
| 192 |
{dup type /stringtype eq {externalhandler} { |
| 193 |
exch dup rfch exch 3 -1 roll |
| 194 |
lookuptarget |
| 195 |
{mark 4 1 roll % put a mark below the source array and the array containing |
| 196 |
% the page |
| 197 |
% the rectangle array of the destination and the FitH parameter |
| 198 |
% and below the Title string |
| 199 |
/Title 4 1 roll % put /Title in front of Title string |
| 200 |
aload pop % put the array elements on the stack |
| 201 |
exch % exchange the FitH parameter and the Rect array |
| 202 |
pop % Get rid of the Rect array |
| 203 |
/Page 3 1 roll % put a /Page in front of the page number |
| 204 |
/View exch % put a /View below the FitH parameter |
| 205 |
[ exch /FitH exch ] % put in the /FitH |
| 206 |
5 -1 roll |
| 207 |
aload pop pop |
| 208 |
0 3 getinterval |
| 209 |
/Rect 3 1 roll |
| 210 |
/Border exch |
| 211 |
/LNK gsave initmat setmatrix pdfmark grestore} |
| 212 |
{pop pop} |
| 213 |
ifelse} ifelse} |
| 214 |
bind def |
| 215 |
|
| 216 |
/pdfm where |
| 217 |
{pop} |
| 218 |
{/pdfm |
| 219 |
/currentdistillerparams where |
| 220 |
{pop |
| 221 |
currentdistillerparams |
| 222 |
dup /CoreDistVersion known |
| 223 |
{/CoreDistVersion get} |
| 224 |
{0} |
| 225 |
ifelse dup |
| 226 |
braindeaddistill le |
| 227 |
{(WARNING: switching to old pdfm because version =)print == /pdfmold} |
| 228 |
{pop /pdfmnew} |
| 229 |
ifelse load |
| 230 |
} |
| 231 |
{/pdfmark where |
| 232 |
{pop {dup type /stringtype eq {externalhandler} |
| 233 |
{2 copy mark 3 1 roll |
| 234 |
{pdfmnew} stackstopped |
| 235 |
{2 copy mark 3 1 roll |
| 236 |
{pdfmold} stackstopped |
| 237 |
{(WARNING: pdfm disabled\012) print |
| 238 |
/pdfm {pop pop} store} |
| 239 |
{(WARNING: new pdfm failed, switching to old pdfm\012)print |
| 240 |
/pdfm /pdfmold load store} |
| 241 |
ifelse} |
| 242 |
{/pdfm /pdfmnew load store} |
| 243 |
ifelse pop pop}ifelse}} |
| 244 |
{{pop pop}} |
| 245 |
ifelse} |
| 246 |
ifelse bind def} |
| 247 |
ifelse |
| 248 |
end def |
| 249 |
%%EndResource |
| 250 |
%%EOF |