Debian Codegraph @

texmf-dist/tex/latex/attachfile2/atfi-dvips.def

raw
1 %%
2 %% This is file `atfi-dvips.def',
3 %% generated with the docstrip utility.
4 %%
5 %% The original source files were:
6 %%
7 %% attachfile2.dtx (with options: `dvips')
8 %%
9 %% This is a generated file.
10 %%
11 %% Project: attachfile2
12 %% Version: 2024-01-18 v2.12
13 %%
14 %% Copyright (C)
15 %% 2005-2010, 2012 Heiko Oberdiek
16 %% 2016-2019 Oberdiek Package Support Group
17 %%
18 %% This work may be distributed and/or modified under the
19 %% conditions of the LaTeX Project Public License, either
20 %% version 1.3c of this license or (at your option) any later
21 %% version. This version of this license is in
22 %% https://www.latex-project.org/lppl/lppl-1-3c.txt
23 %% and the latest version of this license is in
24 %% https://www.latex-project.org/lppl.txt
25 %% and version 1.3 or later is part of all distributions of
26 %% LaTeX version 2005/12/01 or later.
27 %%
28 %% This work has the LPPL maintenance status "maintained".
29 %%
30 %% The Current Maintainers of this work are
31 %% Heiko Oberdiek and the Oberdiek Package Support Group
32 %% https://github.com/ho-tex/attachfile2/issues
33 %%
34 %%
35 %% This work consists of the main source file attachfile2.dtx
36 %% and the derived files
37 %% attachfile2.sty, attachfile2.pdf,
38 %% atfi-dvips.def, atfi-pdftex.def, atfi-dvipdfmx.def, atfi-luatex.def
39 %% pdfatfi.pl, pdfatfi.1.
40 %%
41 \NeedsTeXFormat{LaTeX2e}
42 \ProvidesFile{atfi-dvips.def}%
43 [2024-01-18 v2.12 attachfile2 driver for dvips (HO)]%
44 \def\atfi@literal#1{%
45 \special{ps:atfi_dict begin{#1}atfi_?pdfmark end}%
46 }
47 \def\atfi@header#1{%
48 \special{! #1}%
49 }
50 \atfi@header{%
51 userdict begin 20 dict dup /atfi_dict exch def end begin%
52 /atfi_?pdfmark systemdict %
53 dup/pdfmark known%
54 {%
55 /exec get def%
56 }{%
57 /pop get def%
58 } ifelse%
59 {%
60 %
61 % x y width height atfi_re ->
62 languagelevel 2 ge {%
63 /atfi_rectfill { rectfill } bind def%
64 /atfi_rectstroke { rectstroke } bind def%
65 }{%
66 /atfi_rect {%
67 /atfi_height exch def%
68 /atfi_width exch def%
69 /atfi_x exch def%
70 /atfi_y exch def %
71 newpath %
72 atfi_x atfi_y moveto %
73 atfi_x atfi_width add atfi_y lineto %
74 atfi_x atfi_width add atfi_y atfi_height add lineto %
75 atfi_x atfi_y atfi_height add lineto %
76 closepath%
77 } bind def%
78 /atfi_rectfill {%
79 atfi_rect fill%
80 } bind def%
81 /atfi_rectstroke {%
82 atfi_rect stroke%
83 } bind def%
84 } ifelse%
85 /atfi_curveto_v {%
86 currentpoint 6 2 roll curveto%
87 } bind def%
88 /atfi_curveto_y {%
89 2 copy curveto%
90 } bind def%
91 %
92 % help macro for atfi_convert_date
93 /atfi_two {%
94 dup 10 lt%
95 {%
96 1 string cvs %
97 exch 1 add exch%
98 }{%
99 2 string cvs%
100 } ifelse %
101 putinterval%
102 } bind def%
103 %
104 % <seconds since 1970-01-01> atfi_convert_date -> (D:...Z)
105 /atfi_convert_date {%
106 dup%
107 /atfi_days exch 3600 idiv 24 idiv def%
108 % calc date part
109 /atfi_year 1970 def%
110 {%
111 atfi_year 400 mod 0 eq %
112 atfi_year 100 mod 0 ne %
113 atfi_year 4 mod 0 eq %
114 and or%
115 {366} {365} ifelse %
116 dup atfi_days lt%
117 {%
118 atfi_days exch sub /atfi_days exch def%
119 /atfi_year atfi_year 1 add def%
120 }{%
121 exit%
122 } ifelse%
123 } loop%
124 /atfi_month 1 def%
125 /atfi_days atfi_days 1 add def %
126 31 atfi_days lt%
127 {%
128 atfi_days 31 sub /atfi_days exch def%
129 /atfi_month atfi_month 1 add def %
130 366 eq {29} {28} ifelse dup atfi_days lt%
131 {%
132 atfi_days exch sub /atfi_days exch def%
133 /atfi_month atfi_month 1 add def %
134 31 atfi_days lt%
135 {%
136 atfi_days 31 sub /atfi_days exch def%
137 /atfi_month atfi_month 1 add def %
138 30 atfi_days lt%
139 {%
140 atfi_days 30 sub /atfi_days exch def%
141 /atfi_month atfi_month 1 add def %
142 31 atfi_days lt%
143 {%
144 atfi_days 31 sub /atfi_days exch def%
145 /atfi_month atfi_month 1 add def %
146 30 atfi_days lt%
147 {%
148 atfi_days 30 sub /atfi_days exch def%
149 /atfi_month atfi_month 1 add def %
150 31 atfi_days lt%
151 {%
152 atfi_days 31 sub /atfi_days exch def%
153 /atfi_month atfi_month 1 add def %
154 31 atfi_days lt%
155 {%
156 atfi_days 31 sub /atfi_days exch def%
157 /atfi_month atfi_month 1 add def %
158 30 atfi_days lt%
159 {%
160 atfi_days 30 sub /atfi_days exch def%
161 /atfi_month atfi_month 1 add def %
162 31 atfi_days lt%
163 {%
164 atfi_days 31 sub /atfi_days exch def%
165 /atfi_month atfi_month 1 add def %
166 30 atfi_days lt%
167 {%
168 atfi_days 30 sub /atfi_days exch def%
169 /atfi_month atfi_month 1 add def %
170 31 atfi_days lt%
171 {%
172 atfi_days 31 sub /atfi_days exch def%
173 /atfi_month atfi_month 1 add def%
174 } if%
175 } if%
176 } if%
177 } if%
178 } if%
179 } if%
180 } if%
181 } if%
182 } if%
183 } if%
184 } { pop } ifelse%
185 }{ pop } ifelse %
186 % calc time part
187 3600 24 mul mod %
188 dup 3600 idiv dup /atfi_hour exch def %
189 3600 mul sub %
190 dup 60 idiv dup /atfi_min exch def %
191 60 mul sub %
192 /atfi_sec exch def%
193 (D:19700101000000Z)%
194 dup 2 atfi_year 4 string cvs putinterval %
195 dup 6 atfi_month atfi_two %
196 dup 8 atfi_days atfi_two %
197 dup 10 atfi_hour atfi_two %
198 dup 12 atfi_min atfi_two %
199 dup 14 atfi_sec atfi_two%
200 } bind def %
201 %
202 % <filename> atfi_calc_checksum -> /CheckSum <checksum>
203 % or returns nothing, if MD5Encode is not given
204 false %
205 languagelevel 2 ge {%
206 (MD5Encode)%
207 { pop true or }%
208 (MD5Encode) length string%
209 /Filter %
210 resourceforall%
211 } if%
212 {%
213 /atfi_calc_checksum {%
214 /atfi_checksum 16 string def%
215 /atfi_file exch (r) file def%
216 /atfi_md5sum atfi_checksum /MD5Encode filter def %
217 % not too efficient to read and write byte by byte,
218 % using a buffer is probably faster
219 atfi_size {%
220 atfi_file read%
221 {%
222 atfi_md5sum exch write%
223 } if%
224 } repeat %
225 atfi_md5sum closefile %
226 atfi_file closefile%
227 /CheckSum atfi_checksum%
228 } bind def%
229 }{%
230 /atfi_calc_checksum { pop } bind def%
231 } ifelse%
232 %
233 /atfi_pttobp { 72.27 div 72 mul } bind def%
234 /atfi_pdftodvipsx { 72.27 div Resolution mul } bind def%
235 /atfi_pdftodvipsy { 72.27 div VResolution mul } bind def%
236 %
237 } atfi_?pdfmark %
238 end%
239 }
240 \def\atfi@GSAVE{gsave }
241 \def\atfi@GRESTORE{grestore }
242 \def\atfi@SETLINEWIDTH{setlinewidth }
243 \def\atfi@LINETO{lineto }
244 \def\atfi@MOVETO{moveto }
245 \def\atfi@STROKE{stroke }
246 \def\atfi@FILL{fill }
247 \def\atfi@FILLSTROKE#1#2{gsave #1 fill grestore #2 stroke }
248 \def\atfi@SETRGBCOLORSTROKE{setrgbcolor }
249 \def\atfi@SETRGBCOLORFILL{setrgbcolor }
250 \def\atfi@SETGRAYSTROKE{setgray }
251 \def\atfi@SETGRAYFILL{setgray }
252 \def\atfi@SETCMYKCOLORSTROKE{setcmykcolor }
253 \def\atfi@SETCMYKCOLORFILL{setcmykcolor }
254 \def\atfi@RECTFILL{atfi_rectfill }
255 \def\atfi@RECTSTROKEFILL#1#2#3{%
256 #3%
257 #1%
258 gsave atfi_rectfill grestore %
259 #2%
260 #3%
261 atfi_rectstroke %
262 #1%
263 }
264 \def\atfi@SETMITERLIMIT{setmiterlimit }
265 \def\atfi@SETFLAT{setflat }
266 \def\atfi@SETLINECAP{setlinecap }
267 \def\atfi@CURVETO{curveto }
268 \def\atfi@CURVETOV{atfi_curveto_v }
269 \def\atfi@CURVETOY{atfi_curveto_y }
270 \def\atfi@CLOSEPATH{closepath }
271 \def\atfi@SETLINEJOIN{setlinejoin }
272 \newcounter{atfi@obj}
273 \renewcommand*{\theatfi@obj}{%
274 {atfi_obj_\number\c@atfi@obj}%
275 }
276 \define@key{AtFi@file}{Size}{}
277 \def\atfi@embedfile#1{%
278 \ltx@IfUndefined{atfi@fileobj@#1}{%
279 \atfi@pdfstringdef\atfi@psfilename{#1}%
280 \stepcounter{atfi@obj}%
281 \expandafter\xdef\csname atfi@fileobj@#1\endcsname{\theatfi@obj}%
282 \begingroup
283 \let\atfi@params\ltx@empty
284 \expandafter\let\expandafter\atfi@temp
285 \csname atfi@file@#1\endcsname
286 \ifx\atfi@temp\ltx@empty
287 \let\atfi@temp\relax
288 \fi
289 \ifx\atfi@temp\relax
290 \atfi@pdftexdata{#1}%
291 \else
292 \edef\x{%
293 \noexpand\setkeys{AtFi@file}{\@nameuse{atfi@file@#1}}%
294 }%
295 \x
296 \fi
297 \atfi@literal{%
298 /atfi_filename(\atfi@psfilename)def %
299 atfi_filename status%
300 {%
301 /atfi_created exch def%
302 /atfi_referenced exch def%
303 /atfi_size exch def %
304 pop %
305 [%
306 /_objdef \theatfi@obj
307 /type/stream%
308 /OBJ pdfmark%
309 [%
310 \theatfi@obj
311 <<%
312 /Type/EmbeddedFile%
313 \atfi@mimetype
314 /Params%
315 <<%
316 \atfi@params
317 %
318 /Size atfi_size%
319 %
320 /product where%
321 {%
322 pop %
323 product (Ghostscript) search%
324 {%
325 pop pop pop %
326 \ifatfi@creationdate
327 \else
328 false % TODO: test for windows
329 {%
330 /CreationDate atfi_created atfi_convert_date%
331 } if%
332 \fi
333 \ifatfi@moddate
334 \else
335 /ModDate atfi_referenced atfi_convert_date%
336 \fi
337 } if%
338 } if %
339 \ifatfi@checksum
340 \else
341 atfi_filename atfi_calc_checksum%
342 \fi
343 >>%
344 >>%
345 /PUT pdfmark%
346 [%
347 \theatfi@obj
348 atfi_filename (r) file%
349 /PUT pdfmark%
350 [%
351 \theatfi@obj
352 /CLOSE pdfmark%
353 }{%
354 } ifelse%
355 }%
356 \endgroup
357 }{%
358 }%
359 }
360 \def\atfi@xform@icon{%
361 \stepcounter{atfi@obj}%
362 \edef\atfi@appearanceobj{\theatfi@obj}%
363 \atfi@literal{%
364 [%
365 /_objdef \atfi@appearanceobj
366 /BBox[%
367 0 %
368 0 %
369 \strip@pt\wd\atfi@appearancebox\space atfi_pttobp %
370 \strip@pt\dimexpr\dp\atfi@appearancebox
371 +\ht\atfi@appearancebox\relax\space atfi_pttobp%
372 ]%
373 /BP pdfmark %
374 \csname atfi@acro\atfi@icon@icon @data\endcsname
375 [%
376 /EP pdfmark%
377 }%
378 }
379 \def\atfi@xform{%
380 \stepcounter{atfi@obj}%
381 \edef\atfi@appearanceobj{\theatfi@obj}%
382 \begingroup
383 \setbox\ltx@zero=\hbox{%
384 \atfi@literal{%
385 [%
386 /_objdef \atfi@appearanceobj
387 /BBox[%
388 currentpoint %
389 \strip@pt\dp\atfi@appearancebox\space sub %
390 currentpoint %
391 exch \strip@pt\wd\atfi@appearancebox\space add %
392 exch \strip@pt\ht\atfi@appearancebox\space add%
393 ]%
394 /BP pdfmark %
395 gsave %
396 currentpoint %
397 2 copy translate %
398 72.27 Resolution div 72.27 VResolution div neg scale %
399 exch neg exch neg translate%
400 }%
401 \usebox{\atfi@appearancebox}%
402 \atfi@literal{%
403 grestore%
404 [%
405 /EP pdfmark%
406 }%
407 }%
408 % do not allocate any space for xobject definition
409 \dp\ltx@zero=\z@
410 \ht\ltx@zero=\z@
411 \wd\ltx@zero=\z@
412 \mbox{\usebox\ltx@zero}%
413 \endgroup
414 }
415 \def\atfi@refxform#1{%
416 \raisebox{-\atfi@appearancedepth}{%
417 \atfi@literal{%
418 gsave %
419 currentpoint translate %
420 Resolution 72 div VResolution neg 72 div scale%
421 [#1 /SP pdfmark % hash-ok
422 grestore%
423 }%
424 \makebox[\atfi@appearancewidth]{}%
425 }%
426 \rule{0pt}{\atfi@appearanceheight}%
427 }
428 \def\atfi@insert@file@annot#1{%
429 \rule{0pt}{0pt}%
430 \ifatfi@appearance
431 \def\atfi@appearance@dict{%
432 /AP<<%
433 /N \atfi@appearanceobj
434 /R \atfi@appearanceobj
435 /D \atfi@appearanceobj
436 >>%
437 }%
438 \else
439 \let\atfi@appearance@dict\ltx@empty
440 \fi
441 \ltx@IfUndefined{atfi@fsobj@#1}{%
442 \stepcounter{atfi@obj}%
443 \expandafter
444 \xdef\csname atfi@fsobj@#1\endcsname{\theatfi@obj}%
445 \begingroup
446 \hypersetup{unicode=false}%
447 \atfi@pdfstringdef\atfi@file{#1}%
448 \atfi@literal{%
449 [%
450 /_objdef \theatfi@obj
451 /type/dict%
452 /OBJ pdfmark%
453 [%
454 \theatfi@obj
455 <<%
456 /Type/Filespec%
457 /F(\atfi@file)%
458 \ifx\atfi@ucfilespec\ltx@empty
459 \else
460 /UF(\atfi@ucfilespec)%
461 \fi
462 /EF<<%
463 /F \csname atfi@fileobj@#1\endcsname
464 >>%
465 >>%
466 /PUT pdfmark%
467 }%
468 \endgroup
469 }{%
470 }%
471 \atfi@literal{%
472 [%
473 /Subtype/FileAttachment%
474 \atfi@icon
475 \atfi@color@annot
476 \atfi@author
477 \atfi@date
478 \atfi@annotname
479 \atfi@description
480 \atfi@subject
481 \atfi@appearance@dict
482 /F \theatfi@flags
483 /FS \csname atfi@fsobj@#1\endcsname
484 /Rect[%
485 currentpoint %
486 \strip@pt\dimexpr\atfi@scale\atfi@appearancedepth\relax
487 \space atfi_pdftodvipsy add %
488 currentpoint %
489 exch %
490 \strip@pt\dimexpr\atfi@scale\atfi@appearancewidth\relax
491 \space atfi_pdftodvipsx add %
492 exch %
493 \strip@pt\dimexpr\atfi@scale\atfi@appearanceheight\relax
494 \space atfi_pdftodvipsy sub %
495 ]%
496 /ANN pdfmark%
497 }%
498 \rule{0pt}{\atfi@appearanceheight}%
499 \rule[-\atfi@appearancedepth]{0pt}{\atfi@appearancedepth}%
500 \rule{\atfi@appearancewidth}{0pt}%
501 }
502 \endinput
503 %%
504 %% End of file `atfi-dvips.def'.