1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
2191
2192
2193
2194
2195
2196
2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267
2268
2269
2270
2271
2272
2273
2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
2292
2293
2294
2295
2296
2297
2298
2299
2300
2301
2302
2303
2304
2305
2306
2307
2308
2309
2310
2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
2334
2335
2336
2337
2338
2339
2340
2341
2342
2343
2344
2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
2682
2683
2684
2685
2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733
2734
2735
2736
2737
2738
2739
2740
2741
2742
2743
2744
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762
2763
2764
2765
2766
2767
2768
2769
2770
2771
2772
2773
2774
2775
2776
2777
2778
2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
2795
2796
2797
2798
2799
2800
2801
2802
2803
2804
2805
2806
2807
2808
2809
2810
2811
2812
2813
2814
2815
2816
2817
2818
2819
2820
2821
2822
2823
2824
2825
2826
2827
2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
2884
2885
2886
2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
2917
2918
2919
2920
2921
2922
2923
2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
2956
2957
2958
2959
2960
2961
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
3048
3049
3050
3051
3052
3053
3054
3055
3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
3094
3095
3096
3097
3098
3099
3100
3101
3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
3115
3116
3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
|
% \iffalse meta-comment
%
% Copyright (C) 2005-2010 by
% Heiko Oberdiek <heiko.oberdiek at googlemail.com>
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either
% version 1.3c of this license or (at your option) any later
% version. This version of this license is in
% http://www.latex-project.org/lppl/lppl-1-3c.txt
% and the latest version of this license is in
% http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of
% LaTeX version 2005/12/01 or later.
%
% This work has the LPPL maintenance status "maintained".
%
% This Current Maintainer of this work is Heiko Oberdiek.
%
% This work consists of the main source file attachfile2.dtx
% and the derived files
% attachfile2.sty, attachfile2.pdf, attachfile2.ins, attachfile2.drv,
% atfi-dvips.def, atfi-pdftex.def, atfi-dvipdfmx.def,
% pdfatfi.pl.
%
% Distribution:
% CTAN:macros/latex/contrib/oberdiek/attachfile2.dtx
% CTAN:macros/latex/contrib/oberdiek/attachfile2.pdf
%
% Unpacking:
% (a) If attachfile2.ins is present:
% tex attachfile2.ins
% (b) Without attachfile2.ins:
% tex attachfile2.dtx
% (c) If you insist on using LaTeX
% latex \let\install=y\input{attachfile2.dtx}
% (quote the arguments according to the demands of your shell)
%
% Documentation:
% (a) If attachfile2.drv is present:
% latex attachfile2.drv
% (b) Without attachfile2.drv:
% latex attachfile2.dtx; ...
% The class ltxdoc loads the configuration file ltxdoc.cfg
% if available. Here you can specify further options, e.g.
% use A4 as paper format:
% \PassOptionsToClass{a4paper}{article}
%
% Programm calls to get the documentation (example):
% pdflatex attachfile2.dtx
% makeindex -s gind.ist attachfile2.idx
% pdflatex attachfile2.dtx
% makeindex -s gind.ist attachfile2.idx
% pdflatex attachfile2.dtx
%
% Installation:
% TDS:tex/latex/oberdiek/attachfile2.sty
% TDS:tex/latex/oberdiek/atfi-dvips.def
% TDS:tex/latex/oberdiek/atfi-pdftex.def
% TDS:tex/latex/oberdiek/atfi-dvipdfmx.def
% TDS:scripts/oberdiek/pdfatfi.pl (exec flag)
% TDS:doc/latex/oberdiek/attachfile2.pdf
% TDS:source/latex/oberdiek/attachfile2.dtx
%
%<*ignore>
\begingroup
\catcode123=1 %
\catcode125=2 %
\def\x{LaTeX2e}%
\expandafter\endgroup
\ifcase 0\ifx\install y1\fi\expandafter
\ifx\csname processbatchFile\endcsname\relax\else1\fi
\ifx\fmtname\x\else 1\fi\relax
\else\csname fi\endcsname
%</ignore>
%<*install>
\input docstrip.tex
\Msg{************************************************************************}
\Msg{* Installation}
\Msg{* Package: attachfile2 2010/09/27 v2.6 attach files into PDF (HO)}
\Msg{************************************************************************}
\keepsilent
\askforoverwritefalse
\let\MetaPrefix\relax
\preamble
This is a generated file.
Copyright (C) 2005-2010 by
Heiko Oberdiek <heiko.oberdiek at googlemail.com>
This work may be distributed and/or modified under the
conditions of the LaTeX Project Public License, either
version 1.3c of this license or (at your option) any later
version. This version of this license is in
http://www.latex-project.org/lppl/lppl-1-3c.txt
and the latest version of this license is in
http://www.latex-project.org/lppl.txt
and version 1.3 or later is part of all distributions of
LaTeX version 2005/12/01 or later.
This work has the LPPL maintenance status "maintained".
This Current Maintainer of this work is Heiko Oberdiek.
This work consists of the main source file attachfile2.dtx
and the derived files
attachfile2.sty, attachfile2.pdf, attachfile2.ins, attachfile2.drv,
atfi-dvips.def, atfi-pdftex.def, atfi-dvipdfmx.def,
pdfatfi.pl.
\endpreamble
\let\MetaPrefix\DoubleperCent
\generate{%
\file{attachfile2.ins}{\from{attachfile2.dtx}{install}}%
\file{attachfile2.drv}{\from{attachfile2.dtx}{driver}}%
\usedir{tex/latex/oberdiek}%
\file{attachfile2.sty}{\from{attachfile2.dtx}{package}}%
\file{atfi-dvips.def}{\from{attachfile2.dtx}{dvips}}%
\file{atfi-pdftex.def}{\from{attachfile2.dtx}{pdftex}}%
\file{atfi-dvipdfmx.def}{\from{attachfile2.dtx}{dvipdfmx}}%
\nopreamble
\nopostamble
\usedir{scripts/oberdiek}%
\csname execfiletrue\endcsname
\file{pdfatfi.pl}{\from{attachfile2.dtx}{pdfatfi}}%
}
\catcode32=13\relax% active space
\let =\space%
\Msg{************************************************************************}
\Msg{*}
\Msg{* To finish the installation you have to move the following}
\Msg{* files into a directory searched by TeX:}
\Msg{*}
\Msg{* attachfile2.sty, atfi-dvips.def, atfi-pdftex.def,}
\Msg{* atfi-dvipdfmx.def}
\Msg{*}
\Msg{* And install the following script file:}
\Msg{*}
\Msg{* pdfatfi.pl}
\Msg{*}
\Msg{* To produce the documentation run the file `attachfile2.drv'}
\Msg{* through LaTeX.}
\Msg{*}
\Msg{* Happy TeXing!}
\Msg{*}
\Msg{************************************************************************}
\endbatchfile
%</install>
%<*ignore>
\fi
%</ignore>
%<*driver>
\NeedsTeXFormat{LaTeX2e}
\ProvidesFile{attachfile2.drv}%
[2010/09/27 v2.6 attach files into PDF (HO)]%
\documentclass{ltxdoc}
\usepackage{holtxdoc}[2008/08/11]
\begin{document}
\DocInput{attachfile2.dtx}%
\end{document}
%</driver>
% \fi
%
% \CheckSum{1744}
%
% \CharacterTable
% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
% Digits \0\1\2\3\4\5\6\7\8\9
% Exclamation \! Double quote \" Hash (number) \#
% Dollar \$ Percent \% Ampersand \&
% Acute accent \' Left paren \( Right paren \)
% Asterisk \* Plus \+ Comma \,
% Minus \- Point \. Solidus \/
% Colon \: Semicolon \; Less than \<
% Equals \= Greater than \> Question mark \?
% Commercial at \@ Left bracket \[ Backslash \\
% Right bracket \] Circumflex \^ Underscore \_
% Grave accent \` Left brace \{ Vertical bar \|
% Right brace \} Tilde \~}
%
% \GetFileInfo{attachfile2.drv}
%
% \title{The \xpackage{attachfile2} package}
% \date{2010/09/27 v2.6}
% \author{Heiko Oberdiek\\\xemail{heiko.oberdiek at googlemail.com}}
%
% \maketitle
%
% \begin{abstract}
% This package can be used to attach files to a PDF document.
% It is a further development of Scott Pakin's package
% \xpackage{attachfile} for \pdfTeX. Apart from bug fixes,
% package \xpackage{attachfile2} adds support for \xoption{dvips},
% some new options, gets and writes meta information data about
% the attached files.
% \end{abstract}
%
% \tableofcontents
%
% \section{Documentation}
%
% \subsection{Introduction}
%
% The PDF format (\cite{pdfspec}) allows the inclusion of files
% inside the PDF document. The included files can be bound to an
% annotation on a page. Or they can be recorded in a sorted
% list of embedded files. The packages \xpackage{attachfile}
% or \xpackage{attachfile2} follow the first approach,
% package \xpackage{embedfile} uses the latter method.
%
% \subsubsection{Future development}
%
% My dream is a large package that merges the features of
% all these packages meantioned before:
% \begin{itemize}
% \item Files can be attached to a page.
% \item Files can be attached to the document.
% \item An easy user interface for simple, common tasks and
% beginners.
% \item An interface for the advanced users that want to setup
% every detail.
% \item Support of many drivers (pdftex, dvips, dvipdfm, \dots).
% \item \dots
% \end{itemize}
% However, I have not managed to take the time for this project.
% Instead:
% \begin{itemize}
% \item First I experimented with package \xpackage{attachfile},
% adding driver support, fixing bugs, \dots. The result is
% currently named as \xpackage{attachfile2}. It uses an external
% script to get file properties (size, date, checksum, \dots).
% \item In order to avoid an external program for getting basic
% file properties I provided a patch ``EscapeAndOther'' for
% pdfTeX that was accepted for version 1.30.
% \item Package \xpackage{embedfile} closes a gap left by the
% packages for attaching
% files and allows the embedding of files to the document.
% Also it makes use of the new primitives of \pdfTeX.
% \end{itemize}
% Until this future becomes true, I provide the intermediate
% step \xpackage{attachfile2} at its current state.
% There are many things to do:
% \begin{itemize}
% \item Documentation, documentation, \dots
% \item Improving portability of the Perl script \xfile{pdfatfi.pl}
% (Windows, non-GNU, \dots).
% \item Comfortable program for extracting embeddd files.
% \item Embedding files to the document, see package \xpackage{embedfile}.
% \item Additionally use featurs of \pdfTeX\ 1.30. With a recent
% \pdfTeX\ the Perl script step is then obsolete.
% \item GoToE links.
% \item Layout of PinPush, especially the tip does not scale well.
% \item Driver for \xoption{dvipsone}, similar to \xoption{dvips}, changes:
% \begin{itemize}
% \item coordinate transformation need to be fixed here,
% \xfile{hdvipson.def} contains:
% \begin{quote}
%\begin{verbatim}
%/DvipsToPDF { 65781 div } def
%/PDFToDvips { 65781 mul } def
%\end{verbatim}
% \end{quote}
% \item Syntax for \cs{special}: \xfile{hdvipson.def} contains
% both \verb|\special{! #1}| and
% \verb|\special{headertext= #1}|. Are bothe the same?
% \end{itemize}
% \item File name conversion, see PDF specification:
% \begin{quote}
% \verb|c:\somewhere\foobar.txt| $\rightarrow$
% \verb|/c/somewhere/foobar.txt|
% \end{quote}
% \item Option \xoption{scale} for icons?
% \item Compatibility for \plainTeX.
% \item ToDos for \xfile{atfidvips.def}.
% \end{itemize}
%
% \subsection{User interface}
%
% Basically this package \xpackage{attachfile2} follows the
% user interface of package \xpackage{attachfile},
% look into its documentation (\cite{attachfile}).
%
% \subsubsection{New options}
% \begin{itemize}
% \item Driver options \xoption{dvips}, \xoption{pdftex},
% \xoption{dvipdfmx} and \xoption{xetex} that is an
% alias for \xoption{dvipdfmx}.
% \item Option \xoption{driverfallback} specifies a DVI driver
% if the driver cannot be detected automatically.
% \item New options \xoption{final} and \xoption{draft}.
% \item New option \xoption{scale} for scaling the annotation rectangle.
% \item Options \xoption{file} and \xoption{nofile} for controlling
% the generation of the auxiliary file \xfile{.atfi}.
% \item New option \xoption{ucfilespec} for file names with
% characters outside ASCII (PDF 1.7).
% \end{itemize}
%
% \subsubsection{Option \xoption{color}}
%
% Package \xpackage{attachfile}'s option \xoption{color} only
% understands explicit RGB values as three space separated
% real numbers in the range from 0 to 1.
%
% This package \xpackage{attachfile2} extends the syntax.
% The usual color specifications of packages \xpackage{color}
% or \xpackage{xcolor} may be used. The latter one requires
% that package \xpackage{xcolor} is loaded.
% Without package \xpackage{xcolor} a limited range of
% explicit color specifications are supported, the color models
% \texttt{rgb} and \texttt{gray} (and \texttt{cmyk} if
% package \xpackage{hyperref}'s option \xoption{pdfversion} is set
% to \texttt{1.7} or greater.
%
% Example without package \xpackage{xcolor}:
%\begin{quote}
%\begin{verbatim}
%\documentclass{article}
%\usepackage[color={1 0 .5}]{attachfile2}
% % Spaces in option values in \usepackage or \documentclass
% % must be protected by curly braces. Otherwise LaTeX strips
% % the spaces and the package would see `color=10.5'.
% % This protection is not necessary for \attachfilesetup.
%\attachfilesetup{color=1 0 .5}
%\attachfilesetup{color=[rgb]{1,0,.5}}
%\attachfilesetup{color=[gray]{.5}}
%\end{verbatim}
%\end{quote}
%
% The following example with package \xpackage{xcolor} shows
% additional color specifications:
%\begin{quote}
%\begin{verbatim}
%\documentclass{article}
%\usepackage{xcolor}
%\definecolor{attachfilecolor}{cmyk}{.1,.2,.3,.4}
%\usepackage{color=red}{attachfile2}
%\attachfilesetup{color=red}
%\attachfilesetup{color=attachfilecolor}
%\end{verbatim}
%\end{quote}
%
% \paragraph{For experts.}%
% If the color is used in annotations, the color is converted
% with the help of package \xpackage{xcolor} to RGB.
% PDF versions 1.7 or later also understand color models Gray and
% CMYK. The PDF version is detected if the experimental
% option \xoption{pdfversion}
% of package \xpackage{hyperref} is used, example:
%\begin{quote}
%\begin{verbatim}
%\documentclass{article}
%\usepackage[pdfversion=1.7]{hyperref}
%\usepackage{attachfile2}
%\end{verbatim}
%\end{quote}
% However, currently only driver \xoption{pdftex} also supports
% the actual setting of the PDF version in the output PDF file.
%
% \subsubsection{Perl script \xfile{pdfatfi.pl}}
%
% This package also tries to get and add meta information data,
% such as file size, file date, checksum, \dots.
% As package \xpackage{embedfile} shows the new features
% of \pdfTeX\ 1.30 are very useful for getting this kind of
% data. Since version 2.6 these data are used if available.
%
% For older versions of \pdfTeX\ and \XeTeX\ the Perl script
% \xfile{pdfatfi.pl} is provided to get this data.
% The use of the Perl script is not mandatory. This data can be shown
% by PDF viewers, but they are not a requirement of the PDF specification.
%
% Package \xpackage{attachfile2} and the Perl script communicate
% via an auxiliary file with file extension \xfile{.atfi}. The script
% is used between two \LaTeX\ runs and updates the auxiliary file,
% example for \xoption{dvips}:
% \begin{quote}
%\begin{verbatim}
%latex test
%pdfatfi test
%latex test
%dvips test
%ps2pdf test.ps test.pdf
%\end{verbatim}
% \end{quote}
%
% \subsection{Changes to \xpackage{attachfile}}
%
% Some of the changes I can remember:
% \begin{itemize}
% \item Support for dvips.
% \item Support for dvipdfmx/\XeTeX.
% \item Setting and filling the /Param entry for files
% (file date, file size, \dots).
% \item Perl script \xfile{pdfatfi.pl}.
% \item New options.
% \item Bug fixes.
% \item \dots
% \end{itemize}
%
% \StopEventually{
% }
%
% \section{Implementation}
%
% \subsection{Package}
%
% \begin{macrocode}
%<*package>
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{attachfile2}%
[2010/09/27 v2.6 attach files into PDF (HO)]%
% \end{macrocode}
%
% \subsubsection{Loading of packages}
%
% \begin{macrocode}
\RequirePackage{ifpdf}[2009/04/10]
\RequirePackage{ifxetex}
\RequirePackage{ifluatex}[2009/04/10]
\RequirePackage{keyval}
\RequirePackage{color}
\RequirePackage{infwarerr}[2010/04/08]
\RequirePackage{ltxcmds}[2010/04/26]
\RequirePackage{kvoptions}[2009/07/21]
\RequirePackage{pdftexcmds}[2010/04/01]
\RequirePackage{pdfescape}[2007/11/11]
% \end{macrocode}
% Package \xpackage{hyperref} is needed because of \cs{pdfstringdef}.
% \begin{macrocode}
\RequirePackage{hyperref}
\RequirePackage{hycolor}[2008/07/29]
% \end{macrocode}
%
% \subsubsection{Value checking}
%
% \begin{macro}{\atfi@Match}
% \begin{macrocode}
\ltx@IfUndefined{pdfmatch}{%
\def\atfi@Match#1#2#3#4#5{}%
}{%
\def\atfi@Match#1#2#3{%
\begingroup
\edef\^{\ltx@backslashchar\string^}%
\edef\.{\ltx@backslashchar.}%
\let\#\ltx@hashchar
\edef\[{\ltx@backslashchar[}% ]]
\edef\${\ltx@backslashchar$}%
\let\%\ltx@percentchar
\edef\&{\string&}%
\edef\({\ltx@backslashchar(}%
\edef\){\ltx@backslashchar)}%
\edef\|{\ltx@backslashchar|}%
\edef\*{\ltx@backslashchar*}%
\edef\+{\ltx@backslashchar+}%
\edef\?{\ltx@backslashchar?}%
\edef\{{\ltx@backslashchar\ltx@leftbracechar}%
\edef\}{\ltx@rightbracechar}%
\edef\\{\ltx@backslashchar\ltx@backslashchar}%
\edef\~{\string~}%
\ifcase\pdfmatch#3{#2}{#1} %
\endgroup
\expandafter\ltx@secondoftwo
\or
\endgroup
\expandafter\ltx@firstoftwo
\else
\atfi@Warning{%
Internal error: Wrong pattern!\MessageBreak
--> #2 <--\MessageBreak
Pattern check ignored%
}%
\endgroup
\expandafter\ltx@firstoftwo
\fi
}%
% \end{macrocode}
% \end{macro}
% \begin{macro}{\atfi@PatToken}
% \begin{macrocode}
\def\atfi@PatToken{%
[%
-% first character
!%
\#$\%\&'%
\*\+\.%
0-9%
A-Z%
\^_`%
a-z%
\{\}\|\~%
]+%
}%
% \end{macrocode}
% \end{macro}
% \begin{macro}{\atfi@CR}
% \begin{macrocode}
\begingroup
\lccode64=13 % @
\lowercase{\endgroup
\def\atfi@CR{@}%
}%
% \end{macrocode}
% \end{macro}
% \begin{macro}{\atfi@PatQuotedString}
% \begin{macrocode}
\def\atfi@PatQuotedString{%
"%
([^"\\\atfi@CR]|\\.)*%
"%
}%
% \end{macrocode}
% \end{macro}
% \begin{macrocode}
\ltx@ifpackagelater{ltxcmds}{2010/09/11}{}{%
% \end{macrocode}
% \begin{macro}{\atfi@ltx@leftbracechar}
% \begin{macrocode}
\begingroup
\lccode`0=`\{\relax
\lowercase{\endgroup
\def\ltx@leftbracechar{0}%
}%
% \end{macrocode}
% \end{macro}
% \begin{macro}{\ltx@rightbracechar}
% \begin{macrocode}
\begingroup
\lccode`0=`\}\relax
\lowercase{\endgroup
\def\ltx@rightbracechar{0}%
}%
% \end{macrocode}
% \end{macro}
% \begin{macrocode}
}%
}
% \end{macrocode}
%
% \begin{macro}{\atfi@Warning}
% \begin{macrocode}
\def\atfi@Warning{\PackageWarning{attachfile2}}
% \end{macrocode}
% \end{macro}
%
% \subsubsection{Option declarations}
%
% \begin{macrocode}
\SetupKeyvalOptions{%
family=AtFi,%
prefix=atfi@%
}
% \end{macrocode}
% \begin{macro}{\atfi@setup}
% \begin{macrocode}
\def\atfi@setup{\setkeys{AtFi}}
% \end{macrocode}
% \end{macro}
%
% Options \xoption{draft} and \xoption{final}.
% \begin{macrocode}
\DeclareBoolOption{draft}
\DeclareComplementaryOption{final}{draft}
% \end{macrocode}
%
% Option \xoption{mimetype}.
% \begin{macro}{\atfi@mimetype}
% \begin{macrocode}
\def\atfi@mimetype{}
% \end{macrocode}
% \end{macro}
% \begin{macrocode}
\define@key{AtFi}{mimetype}{%
\edef\atfi@mimetype{#1}%
\ifx\atfi@mimetype\ltx@empty
\else
\atfi@Match\atfi@mimetype{%
^(application|audio|image|model|text|video|x-\atfi@PatToken)%
/%
([a-z\-\+_\.0-9]+)%
(; ?\atfi@PatToken=(\atfi@PatToken|\atfi@PatQuotedString))*$%
}{icase}{}{%
\atfi@Warning{%
Invalid value `\atfi@mimetype'\MessageBreak
of option `mimetype'.\MessageBreak
Value is discarded%
}%
\let\atfi@mimetype\ltx@empty
}%
\fi
\ifx\atfi@mimetype\ltx@empty
\else
\EdefEscapeName\atfi@mimetype{\atfi@mimetype}%
\edef\atfi@mimetype{/Subtype/\atfi@mimetype}%
\fi
}
% \end{macrocode}
%
% Option \xoption{icon}
% \begin{macrocode}
\define@key{AtFi}{icon}{%
\def\atfi@icon{/Name/#1}%
\def\atfi@icon@icon{#1}%
}
\atfi@setup{icon=PushPin}
% \end{macrocode}
%
% Option \xoption{color}
% \begin{macrocode}
\define@key{AtFi}{color}{%
\HyColor@AttachfileColor{#1}%
\atfi@color@tex\atfi@color@inline\atfi@color@annot
{attachfile2}{color}%
}
\atfi@setup{color=1 0.9255 0.7765}
% \end{macrocode}
%
% time options timezone and date
% \begin{macro}{\atfi@pad@ii}
% \begin{macrocode}
\def\atfi@pad@ii#1{%
\ifnum#1>9 %
\number#1%
\else
0\number#1%
\fi%
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{atfi@timezone}
% \begin{macrocode}
\let\atfi@timezone\ltx@empty
% \end{macrocode}
% \end{macro}
% \begin{macrocode}
\define@key{AtFi}{timezone}{\def\atfi@timezone{#1}}
% \end{macrocode}
% \begin{macro}{\atfi@time}
% \begin{macrocode}
\edef\atfi@time{\the\time}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\atfi@hours}
% \begin{macrocode}
\def\atfi@hours{%
\numexpr\dimexpr0.01667\dimexpr\atfi@time sp\relax\relax\relax
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\atfi@minutes}
% \begin{macrocode}
\def\atfi@minutes{%
\numexpr\atfi@time-60*\atfi@hours\relax
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\atfi@seconds}
% \begin{macrocode}
\def\atfi@seconds{0}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\atfi@date}
% \begin{macrocode}
\def\atfi@date{%
/M(D:\the\year
\atfi@pad@ii\month
\atfi@pad@ii\day
\atfi@pad@ii\atfi@hours
\atfi@pad@ii\atfi@minutes
\atfi@pad@ii\atfi@seconds
\atfi@timezone)%
}
% \end{macrocode}
% \end{macro}
% \begin{macrocode}
\define@key{AtFi}{date}{%
\EdefEscapeString\atfi@date{#1}%
\edef\atfi@date{/M(\atfi@date)}%
}
% \end{macrocode}
%
% Text options author, description, and subject
% \begin{macro}{\atfi@pdfstringdef}
% \begin{macrocode}
\DeclareRobustCommand{\atfi@pdfstringdef}[2]{%
\pdfstringdef\atfi@temp@string{#2}%
\edef#1{\atfi@temp@string}%
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\atfi@NoValue}
% \begin{macrocode}
\def\atfi@NoValue{\NoValue}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\atfi@DefNoValueName}
% \begin{macrocode}
\def\atfi@DefNoValueName#1#2#3{%
\def#1{#3}%
\ifx#1\atfi@NoValue
\let#1\ltx@empty
\else
\atfi@pdfstringdef#1{#1}%
\edef#1{/#2(#1)}%
\fi
}
% \end{macrocode}
% \end{macro}
%
% Name for annotation to be used in GoToE actions
% \begin{macro}{\atfi@annotname}
% \begin{macrocode}
\let\atfi@annotname\ltx@empty
% \end{macrocode}
% \end{macro}
% \begin{macrocode}
\define@key{AtFi}{annotname}[\NoValue]{%
\atfi@DefNoValueName\atfi@annotname{NM}{#1}%
}
% \end{macrocode}
%
% Option \xoption{author}.
% \begin{macro}{\atfi@author}
% \begin{macrocode}
\def\atfi@author{}
% \end{macrocode}
% \end{macro}
% \begin{macrocode}
\define@key{AtFi}{author}[\NoValue]{%
\atfi@DefNoValueName\atfi@author{T}{#1}%
}
% \end{macrocode}
%
% Option \xoption{description}.
% \begin{macro}{\atfi@description}
% \begin{macrocode}
\def\atfi@description{}
% \end{macrocode}
% \end{macro}
% \begin{macrocode}
\define@key{AtFi}{description}[\NoValue]{%
\atfi@DefNoValueName\atfi@description{Contents}{#1}%
}
% \end{macrocode}
%
% Option \xoption{subject}.
% \begin{macro}{\atfi@subject}
% \begin{macrocode}
\def\atfi@subject{}
% \end{macrocode}
% \end{macro}
% \begin{macrocode}
\define@key{AtFi}{subject}[\NoValue]{%
\atfi@DefNoValueName\atfi@subject{Subj}{#1}%
}
% \end{macrocode}
%
% Option \xoption{print}.
% \begin{macrocode}
\DeclareBoolOption[true]{print}
% \end{macrocode}
%
% Option \xoption{zoom}.
% \begin{macrocode}
\DeclareBoolOption[true]{zoom}
% \end{macrocode}
%
% Option \xoption{appearance}.
% \begin{macrocode}
\DeclareBoolOption[true]{appearance}
% \end{macrocode}
%
% Option \xoption{scale}.
% \begin{macrocode}
\DeclareStringOption[1]{scale}
% \end{macrocode}
%
% Option \xoption{ucfilespec}.
% \begin{macro}{\atfi@ucfilespec}
% \begin{macrocode}
\def\atfi@ucfilespec{}
% \end{macrocode}
% \end{macro}
% \begin{macrocode}
\define@key{AtFi}{ucfilespec}[1]{%
\def\atfi@ucfilespec{#1}%
\ifx\atfi@ucfilespec\ltx@empty
\else
\atfi@pdfstringdef\atfi@ucfilespec{#1}%
\fi
}
% \end{macrocode}
%
% Option \xoption{nofiles}.
% \begin{macrocode}
\DeclareBoolOption{nofiles}
% \end{macrocode}
%
% Driver options.
% \begin{macrocode}
\let\atfi@driver\ltx@empty
\def\atfi@driver@pdftex{pdftex}
\def\atfi@driver@dvips{dvips}
\def\atfi@driver@dvipdfmx{dvipdfmx}
% \end{macrocode}
% \begin{macrocode}
\DeclareVoidOption{pdftex}{%
\let\atfi@driver\atfi@driver@pdftex
}
\DeclareVoidOption{dvips}{%
\let\atfi@driver\atfi@driver@dvips
}
\DeclareVoidOption{dvipdfmx}{%
\let\atfi@driver\atfi@driver@dvipdfmx
}
\DeclareVoidOption{xetex}{%
\let\atfi@driver\atfi@driver@dvipdfmx
}
% \end{macrocode}
% \begin{macrocode}
\DeclareStringOption{driverfallback}
% \end{macrocode}
%
% \begin{macro}{\attachfilesetup}
% \begin{macrocode}
\DeclareRobustCommand{\attachfilesetup}[1]{\setkeys{AtFi}{#1}}
% \end{macrocode}
% \end{macro}
%
% \begin{macrocode}
\DeclareLocalOptions{%
annotname,%
appearance,%
author,%
color,%
date,%
description,%
icon,%
mimetype,%
nofiles,%
print,%
scale,%
subject,%
timezone,%
ucfilespec,%
zoom,%
}
% \end{macrocode}
%
% \subsubsection{Option calling}
%
% Timezone setting, \dots
% \begin{macrocode}
\InputIfFileExists{attachfile.cfg}{}{}
% \end{macrocode}
% \begin{macrocode}
\ProcessKeyvalOptions*
% \end{macrocode}
%
% \begin{macro}{\atfi@DisableOption}
% \begin{macrocode}
\def\atfi@DisableOption{%
\DisableKeyvalOption[action=error,package=attachfile2]{AtFi}%
}
% \end{macrocode}
% \end{macro}
%
% \subsubsection{Evaluate driver options}
%
% \begin{macrocode}
\ifpdf
% ignoring other driver options
\let\atfi@driver\atfi@driver@pdftex
\else
\ifx\atfi@driver\atfi@driver@pdftex
\let\atfi@driver\ltx@empty
\PackageError{attachfile2}{%
Wrong driver option `pdftex',\MessageBreak
because pdfTeX in PDF mode is not detected%
}\@ehc
\fi
\ifxetex
\let\atfi@driver\atfi@driver@dvipdfmx
\else
\ifx\atfi@driver\ltx@empty
\ifx\atfi@driverfallback\ltx@empty
\else
\expandafter\let\expandafter\atfi@driver
\csname atfi@driver@\atfi@driverfallback\endcsname
\ifx\atfi@driver\atfi@driver@dvips
\else
\ifx\atfi@driver\atfi@driver@dvipdfmx
\else
\let\atfi@driver\ltx@empty
\PackageWarningNoLine{attachfile2}{%
Option `driverfallback' with unsupported\MessageBreak
DVI driver (\atfi@driverfallback)%
}%
\fi
\fi
\fi
\ifx\atfi@driver\ltx@empty
\PackageWarningNoLine{attachfile2}{%
Driver is not specified,\MessageBreak
enforce draft settings%
}%
\atfi@drafttrue
\fi
\fi
\fi
\fi
% \end{macrocode}
% \begin{macrocode}
\atfi@DisableOption{pdftex}
\atfi@DisableOption{dvips}
\atfi@DisableOption{dvipdfmx}
\atfi@DisableOption{xetex}
\atfi@DisableOption{driverfallback}
% \end{macrocode}
%
% \subsubsection{Evaluate options \xoption{draft}/\xoption{final}}
%
% \begin{macro}{\notextattachfile}
% \begin{macrocode}
\DeclareRobustCommand{\notextattachfile}[2][]{%
\begingroup
\atfi@setup{#1}%
\ifatfi@print
\leavevmode
\begingroup
\HyColor@UseColor\atfi@color@tex
#2\strut
\endgroup
\else
\sbox\ltx@zero{#2\strut}%
\makebox[\wd0]{}%
\fi
\endgroup
}
% \end{macrocode}
% \end{macro}
% \begin{macrocode}
\atfi@DisableOption{draft}%
\atfi@DisableOption{final}%
\ifatfi@draft
\def\atfi@dummy@pushpin{%
\raisebox{-1.25bp}{\parbox[b][14bp]{24bp}{}}%
}%
\DeclareRobustCommand{\textattachfile}[3][]{%
\notextattachfile[{#1}]{#3}%
}%
\DeclareRobustCommand{\noattachfile}[1][]{%
\notextattachfile[{#1}]{\atfi@dummy@pushpin}%
}%
\DeclareRobustCommand{\attachfile}[2][]{%
\noattachfile[{#1}]%
}%
\expandafter\endinput
\fi
% \end{macrocode}
%
% \subsubsection{Load driver file}
%
% \begin{macrocode}
\input{atfi-\atfi@driver.def}
% \end{macrocode}
%
% \subsubsection{Graphics}
%
% \begin{macro}{\atfi@acroGraph@data}
% \begin{macrocode}
\def\atfi@acroGraph@data{%
\atfi@GSAVE
0.5 \atfi@SETGRAYFILL
1.1133 0 20.7202 18.2754 \atfi@RECTFILL
0 \atfi@SETFLAT
0.5 \atfi@SETLINEWIDTH
4 \atfi@SETMITERLIMIT
\atfi@RECTSTROKEFILL{%
1 \atfi@SETGRAYFILL
}{%
0 \atfi@SETGRAYSTROKE
}{%
0.25 1.6453 20.145 17.7715 %
}%
0 \atfi@SETGRAYFILL
2.7319 4.1367 3.9571 13.8867 \atfi@RECTFILL
8.7031 4.1367 3.9571 9.8867 \atfi@RECTFILL
14.7471 4.1367 3.9571 11.8867 \atfi@RECTFILL
\atfi@color@inline{FILL}%
1.689 3.0938 3.9571 13.8867 \atfi@RECTFILL
7.6602 3.0938 3.9571 9.8867 \atfi@RECTFILL
13.7041 3.0938 3.9571 11.8867 \atfi@RECTFILL
\atfi@GRESTORE
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\atfi@acroGraph}
% \begin{macrocode}
\def\atfi@acroGraph{%
\raisebox{-1.5bp}{\parbox[b][20bp]{22bp}{%
\rule{0pt}{0pt}\atfi@literal{\atfi@acroGraph@data}}%
}%
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\atfi@acroPaperclip@data}
% \begin{macrocode}
\newcommand{\atfi@acroPaperclip@data}{%
\atfi@GSAVE
0.75 \atfi@SETGRAYSTROKE
0 \atfi@SETFLAT
2.5 \atfi@SETLINEWIDTH
1 \atfi@SETLINECAP
4 \atfi@SETMITERLIMIT
1.9619 11.7559 \atfi@MOVETO
1.9619 3.3037 1.9619 2.5059 \atfi@CURVETOV
1.9619 1.707 4.0947 1.25 \atfi@CURVETOY
7.4141 1.25 \atfi@LINETO
9.4292 1.8223 9.4292 3.3066 \atfi@CURVETOV
9.4292 4.79 9.4292 16.8945 \atfi@CURVETOY
9.7852 18.1514 8.481 18.1514 \atfi@CURVETOV
7.1768 18.1514 5.1616 18.1514 \atfi@CURVETOY
3.8574 17.9209 3.8574 16.8945 \atfi@CURVETOV
3.8574 15.8652 3.8574 6.6172 \atfi@CURVETOY
4.3325 5.418 5.1025 5.418 \atfi@CURVETOV
5.8726 5.418 6.5845 5.418 \atfi@CURVETOY
7.6812 5.6455 7.6812 6.4736 \atfi@CURVETOV
7.6812 7.3027 7.6812 11.5264 \atfi@CURVETOY
\atfi@STROKE
0 \atfi@SETGRAYSTROKE
1.2495 12.4404 \atfi@MOVETO
1.2495 3.9883 1.2495 3.1895 \atfi@CURVETOV
1.2495 2.3906 3.3833 1.9326 \atfi@CURVETOY
6.7026 1.9326 \atfi@LINETO
8.7178 2.5068 8.7178 3.9902 \atfi@CURVETOV
8.7178 5.4736 8.7178 17.5781 \atfi@CURVETOY
9.0732 18.834 7.769 18.834 \atfi@CURVETOV
6.4653 18.834 4.4497 18.834 \atfi@CURVETOY
3.146 18.6055 3.146 17.5781 \atfi@CURVETOV
3.146 16.5498 3.146 7.3018 \atfi@CURVETOY
3.6201 6.1016 4.3911 6.1016 \atfi@CURVETOV
5.1611 6.1016 5.873 6.1016 \atfi@CURVETOY
6.9692 6.3301 6.9692 7.1572 \atfi@CURVETOV
6.9692 7.9863 6.9692 12.21 \atfi@CURVETOY
\atfi@STROKE
\atfi@color@inline{STROKE}%
1 \atfi@SETLINEWIDTH
1.2495 12.4404 \atfi@MOVETO
1.2495 3.9883 1.2495 3.1895 \atfi@CURVETOV
1.2495 2.3906 3.3833 1.9326 \atfi@CURVETOY
6.7026 1.9326 \atfi@LINETO
8.7178 2.5068 8.7178 3.9902 \atfi@CURVETOV
8.7178 5.4736 8.7178 17.5781 \atfi@CURVETOY
9.0732 18.834 7.769 18.834 \atfi@CURVETOV
6.4653 18.834 4.4497 18.834 \atfi@CURVETOY
3.146 18.6055 3.146 17.5781 \atfi@CURVETOV
3.146 16.5498 3.146 7.3018 \atfi@CURVETOY
3.6201 6.1016 4.3911 6.1016 \atfi@CURVETOV
5.1611 6.1016 5.873 6.1016 \atfi@CURVETOY
6.9692 6.3301 6.9692 7.1572 \atfi@CURVETOV
6.9692 7.9863 6.9692 12.21 \atfi@CURVETOY
\atfi@STROKE
\atfi@GRESTORE
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\atfi@acroPaperclip}
% \begin{macrocode}
\def\atfi@acroPaperclip{%
\raisebox{-1.25bp}{\parbox[b][21bp]{12bp}{%
\rule{0pt}{0pt}\atfi@literal{\atfi@acroPaperclip@data}}%
}%
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\atfi@acroPushPin@data}
% \begin{macrocode}
\def\atfi@acroPushPin@data{%
\atfi@GSAVE
1 \atfi@SETLINEWIDTH
1 6 \atfi@MOVETO
11 6 \atfi@LINETO
11 13 \atfi@LINETO
12 13 \atfi@LINETO
14 11 \atfi@LINETO
21 11 \atfi@LINETO
22 12 \atfi@LINETO
23 12 \atfi@LINETO
23 2 \atfi@LINETO
22 2 \atfi@LINETO
21 3 \atfi@LINETO
14 3 \atfi@LINETO
12 1 \atfi@LINETO
11 1 \atfi@LINETO
11 6 \atfi@LINETO
\atfi@FILLSTROKE{%
\atfi@color@inline{FILL}%
}{%
0 \atfi@SETGRAYSTROKE
}%
0.5 \atfi@SETGRAYSTROKE
0 7 \atfi@MOVETO
10 7 \atfi@LINETO
10 8 \atfi@LINETO
1 8 \atfi@LINETO
\atfi@STROKE
1 \atfi@SETGRAYSTROKE
12 12 \atfi@MOVETO
14 10 \atfi@LINETO
22 10 \atfi@LINETO
22 11 \atfi@LINETO
\atfi@STROKE
\atfi@GRESTORE
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\atfi@acroPushPin}
% \begin{macrocode}
\def\atfi@acroPushPin{%
\raisebox{-1.25bp}{\parbox[b][14bp]{24bp}{%
\rule{0pt}{0pt}\atfi@literal{\atfi@acroPushPin@data}}%
}%
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\atfi@acroTag@data}
% \begin{macrocode}
\def\atfi@acroTag@data{%
\atfi@GSAVE
0.5 \atfi@SETGRAYFILL
10.0542 14.9873 \atfi@MOVETO
24.27 14.9873 \atfi@LINETO
25.252 14.0059 \atfi@LINETO
25.252 1.1455 \atfi@LINETO
24.1064 0 \atfi@LINETO
9.9609 0 \atfi@LINETO
6.0327 6.0088 \atfi@LINETO
6.0327 9.002 \atfi@LINETO
10.0542 14.9873 \atfi@LINETO
9.3994 9.376 \atfi@MOVETO
8.5215 9.376 7.8096 8.5596 7.8096 7.5527 \atfi@CURVETO
7.8096 6.5449 8.5215 5.7285 9.3994 5.7285 \atfi@CURVETO
10.2778 5.7285 10.9897 6.5449 10.9897 7.5527 \atfi@CURVETO
10.9897 8.5596 10.2778 9.376 9.3994 9.376 \atfi@CURVETO
\atfi@CLOSEPATH
\atfi@FILL
0 \atfi@SETFLAT
0.5 \atfi@SETLINEWIDTH
4 \atfi@SETMITERLIMIT
1 \atfi@SETLINEJOIN
8.5107 16.5313 \atfi@MOVETO
22.7266 16.5313 \atfi@LINETO
23.7085 15.5488 \atfi@LINETO
23.7085 2.6895 \atfi@LINETO
22.563 1.543 \atfi@LINETO
8.4175 1.543 \atfi@LINETO
4.4893 7.5527 \atfi@LINETO
4.4893 10.5449 \atfi@LINETO
8.5107 16.5313 \atfi@LINETO
7.856 10.9199 \atfi@MOVETO
6.978 10.9199 6.2661 10.1035 6.2661 9.0957 \atfi@CURVETO
6.2661 8.0879 6.978 7.2715 7.856 7.2715 \atfi@CURVETO
8.7344 7.2715 9.4463 8.0879 9.4463 9.0957 \atfi@CURVETO
9.4463 10.1035 8.7344 10.9199 7.856 10.9199 \atfi@CURVETO
\atfi@CLOSEPATH
\atfi@FILLSTROKE{%
\atfi@color@inline{FILL}%
}{%
0 \atfi@SETGRAYSTROKE
}%
1 \atfi@SETLINEWIDTH
12.3291 12.2656 \atfi@MOVETO
21.1206 12.2656 \atfi@LINETO
\atfi@STROKE
12.3291 9.1797 \atfi@MOVETO
21.1206 9.1797 \atfi@LINETO
\atfi@STROKE
12.3291 6.1875 \atfi@MOVETO
21.1206 6.1875 \atfi@LINETO
\atfi@STROKE
% 0 \atfi@SETGRAYSTROKE % redundant?
0.5 \atfi@SETLINEWIDTH
0 9.0488 \atfi@MOVETO
6.2661 9.0957 \atfi@LINETO
\atfi@STROKE
1.4028 5.2148 \atfi@MOVETO
1.4028 9.6094 \atfi@LINETO
1.6831 10.6387 2.4316 10.6387 \atfi@CURVETOV
3.6475 10.6387 3.5542 9.0488 \atfi@CURVETOY
\atfi@STROKE
\atfi@GRESTORE
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\atfi@acroTag}
% \begin{macrocode}
\def\atfi@acroTag{%
\raisebox{-1.6bp}{\parbox[b][17bp]{25bp}{%
\rule{0pt}{0pt}\atfi@literal{\atfi@acroTag@data}}%
}%
}
% \end{macrocode}
% \end{macro}
%
% \subsubsection{Reading the \xext{atfi} file}
%
% Commands used in \cs{jobname}\xext{atfi}:
% \begin{itemize}
% \item |attachfile@timezone{<timezone in PDF format>}|
% \item
%\begin{verbatim}
%\attachfile@file[
% Size=<size>,
% CreationDate=<date>, % <date> local time without "D:" and timezone
% ModDateTZ=<date+TZ>,
% ModDate=<date>,
% CheckSum=<checksum>
%]{<filename as hex string>}
%\end{verbatim}
% \end{itemize}
%
% \begin{macro}{\attachfile@timezone}
% \begin{macrocode}
\def\attachfile@timezone#1{%
\ifx\\#1\\%
% no timezone information given
\else
\def\atfi@timezone{#1}%
\fi
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\attachfile@file}
% \begin{macrocode}
\newcommand*{\attachfile@file}[2][]{%
\EdefUnescapeHex\atfi@filename{#2}%
\ifx\atfi@filename\ltx@empty
\PackageError{attachfile2}{Empty file name}\@ehc
\else
\@namedef{atfi@file@\atfi@filename}{#1}%
\fi
}
% \end{macrocode}
% \end{macro}
%
% \begin{macrocode}
\InputIfFileExists{\jobname.atfi}{}{}%
% \end{macrocode}
%
% \begin{macrocode}
\newif\ifatfi@checksum
\define@key{AtFi@file}{CheckSum}{%
\atfi@checksumtrue
\edef\atfi@params{\atfi@params/CheckSum<#1>}%
}
% \end{macrocode}
% \begin{macrocode}
\newif\ifatfi@creationdate
\define@key{AtFi@file}{CreationDateTZ}{%
\ifatfi@creationdate
\else
\atfi@creationdatetrue
\edef\atfi@params{%
\atfi@params
/CreationDate(#1)%
}%
\fi
}
% \end{macrocode}
% \begin{macrocode}
\define@key{AtFi@file}{CreationDate}{%
\ifatfi@creationdate
\else
\atfi@creationdatetrue
\edef\atfi@params{%
\atfi@params
/CreationDate(#1\atfi@timezone)%
}%
\fi
}
% \end{macrocode}
% \begin{macrocode}
\newif\ifatfi@moddate
\define@key{AtFi@file}{ModDateTZ}{%
\ifatfi@moddate
\else
\atfi@moddatetrue
\edef\atfi@params{%
\atfi@params
/ModDate(#1)%
}%
\fi
}
% \end{macrocode}
% \begin{macrocode}
\define@key{AtFi@file}{ModDate}{%
\ifatfi@moddate
\else
\atfi@moddatetrue
\edef\atfi@params{%
\atfi@params
/ModDate(D:#1\atfi@timezone)%
}%
\fi
}
% \end{macrocode}
%
% \begin{macro}{\atfi@pdftexdata}
% \begin{macrocode}
\let\atfi@temp\ltx@one
\ltx@IfUndefined{pdf@filesize}{%
\let\atfi@temp\ltx@zero
}{}
\ltx@IfUndefined{pdf@filemoddate}{%
\let\atfi@temp\ltx@zero
}{}
\ltx@IfUndefined{pdf@filemdfivesum}{%
\let\atfi@temp\ltx@zero
}{}
\ifcase\atfi@temp
\let\atfi@pdftexdata\ltx@gobble
\or
\def\atfi@pdftexdata#1{%
\edef\atfi@temp{\pdf@filesize{#1}}%
\ifx\atfi@temp\ltx@empty
\else
\setkeys{AtFi@file}{Size=\atfi@temp}%
\edef\atfi@temp{\pdf@filemoddate{#1}}%
\ifx\atfi@temp\ltx@empty
\else
\setkeys{AtFi@file}{ModDateTZ=\atfi@temp}%
\fi
\edef\atfi@temp{\pdf@filemdfivesum{#1}}%
\ifx\atfi@temp\ltx@empty
\else
\setkeys{AtFi@file}{CheckSum=\atfi@temp}%
\fi
\fi
}%
\fi
% \end{macrocode}
% \end{macro}
%
% \subsubsection{Writing the \xext{atfi} file}
%
% Respect \cs{nofiles} and option \xoption{nofiles}.
% \cs{nofiles} has more weight than option \xoption{nofiles}.
% \begin{macrocode}
\if@filesw
\else
\atfi@nofilestrue
\fi
\ifatfi@nofiles
\PackageInfo{attachfile2}{%
File `\jobname.atfi' will not be written because of\MessageBreak
\string\nofiles\space or option `nofiles'%
}%
% \end{macrocode}
% \begin{macro}{\atfi@writefile}
% \begin{macrocode}
\let\atfi@writefile\ltx@gobble
% \end{macrocode}
% \end{macro}
% \begin{macrocode}
\else
% \end{macrocode}
% \begin{macro}{\atfi@stream}
% \begin{macrocode}
\newwrite\atfi@stream
% \end{macrocode}
% \end{macro}
% \begin{macrocode}
\immediate\openout\atfi@stream=\jobname.atfi\relax
\immediate\write\atfi@stream{%
\string\attachfile@timezone{\atfi@timezone}%
}%
% \end{macrocode}
% \begin{macro}{\atfi@writefile}
% \begin{macrocode}
\def\atfi@writefile#1{%
\begingroup
\EdefEscapeHex\atfi@temp{#1}%
\immediate\write\atfi@stream{%
\string\attachfile@file[%
\ltx@ifundefined{atfi@file@#1}{}{\@nameuse{atfi@file@#1}}%
]{\atfi@temp}%
}%
\endgroup
}%
% \end{macrocode}
% \end{macro}
% \begin{macrocode}
\fi
\atfi@DisableOption{nofiles}
% \end{macrocode}
%
% \begin{macro}{\atfi@attachfile}
% \begin{macrocode}
\def\atfi@attachfile#1#2{%
\ltx@IfUndefined{atfi@fileobj@#2}{%
\atfi@writefile{#2}%
}{%
% don't need duplicates
}%
\atfi@setup{#1}%
\atfi@embedfile{#2}%
\atfi@set@appearance@icon
\atfi@flags@to@int
\atfi@insert@file@annot{#2}%
\endgroup
}
% \end{macrocode}
% \end{macro}
%
% \subsubsection{Annotation appearance}
%
% \begin{macro}{\atfi@appearancewidth}
% \begin{macrocode}
\newlength{\atfi@appearancewidth}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\atfi@appearanceheight}
% \begin{macrocode}
\newlength{\atfi@appearanceheight}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\atfi@appearancedepth}
% \begin{macrocode}
\newlength{\atfi@appearancedepth}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\atfi@appearancebox}
% \begin{macrocode}
\newsavebox{\atfi@appearancebox}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\atfi@set@appearance@icon}
% \begin{macrocode}
\def\atfi@set@appearance@icon{%
\ltx@IfUndefined{atfi@appobj@\atfi@icon@icon}{%
\savebox{\atfi@appearancebox}{%
\@nameuse{atfi@acro\atfi@icon@icon}%
}%
\expandafter
\xdef\csname atfi@appwidth@\atfi@icon@icon\endcsname{%
\the\wd\atfi@appearancebox
}%
\expandafter
\xdef\csname atfi@appheight@\atfi@icon@icon\endcsname{%
\the\ht\atfi@appearancebox
}%
\expandafter
\xdef\csname atfi@appdepth@\atfi@icon@icon\endcsname{%
\the\dp\atfi@appearancebox
}%
\atfi@xform@icon
\global\expandafter\let
\csname atfi@appobj@\atfi@icon@icon\endcsname
\atfi@appearanceobj
}{%
}%
% optimization: \setlength dropped
\atfi@appearancewidth=%
\@nameuse{atfi@appwidth@\atfi@icon@icon}\relax
\atfi@appearanceheight=%
\@nameuse{atfi@appheight@\atfi@icon@icon}\relax
\atfi@appearancedepth=%
\@nameuse{atfi@appdepth@\atfi@icon@icon}\relax
\expandafter\let\expandafter\atfi@appearanceobj
\csname atfi@appobj@\atfi@icon@icon\endcsname
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\atfi@set@appearance}
% \begin{macrocode}
\def\atfi@set@appearance#1{%
\savebox{\atfi@appearancebox}{#1}%
\atfi@appearancewidth=\wd\atfi@appearancebox
\atfi@appearanceheight=\ht\atfi@appearancebox
\atfi@appearancedepth=\dp\atfi@appearancebox
\atfi@xform
}
% \end{macrocode}
% \end{macro}
%
% \begin{macrocode}
\newcounter{atfi@flags}
% \end{macrocode}
% \begin{macro}{\atfi@flags@to@int}
% \begin{macrocode}
\DeclareRobustCommand{\atfi@flags@to@int}{%
\setcounter{atfi@flags}{0}%
\ifatfi@print
\addtocounter{atfi@flags}{4}%
\fi%
\ifatfi@zoom
\else
\addtocounter{atfi@flags}{8}%
\fi%
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\atfi@textattachfile}
% \begin{macrocode}
\def\atfi@textattachfile#1#2{%
\endgroup
\atfi@textattachfile@i{#1}{#2}%
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\atfi@textattachfile@i}
% \begin{macrocode}
\def\atfi@textattachfile@i#1#2#3{%
\ltx@IfUndefined{atfi@fileobj@#2}{%
\atfi@writefile{#2}%
}{%
% don't need duplicates
}%
\atfi@setup{#1}%
\atfi@embedfile{#2}%
\atfi@set@appearance{%
\leavevmode
\begingroup
\HyColor@UseColor\atfi@color@tex
#3\strut
\endgroup
}%
\atfi@flags@to@int
\atfi@insert@file@annot{#2}%
\endgroup
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\attachfile}
% \begin{macrocode}
\DeclareRobustCommand{\attachfile}[1][]{%
\begingroup
\let\do\@makeother
\dospecials
\catcode`\{=1\relax
\catcode`\}=2\relax
\atfi@attachfile{#1}%
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\textattachfile}
% \begin{macrocode}
\DeclareRobustCommand{\textattachfile}[1][]{%
\begingroup
\begingroup
\let\do\@makeother
\dospecials
\catcode`\{=1\relax
\catcode`\}=2\relax
\atfi@textattachfile{#1}%
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\noattachfile}
% \begin{macrocode}
\DeclareRobustCommand{\noattachfile}[1][]{%
\begingroup
\atfi@setup{#1}%
\atfi@set@appearance@icon
\ifatfi@print
\expandafter
\atfi@refxform\csname atfi@appobj@\atfi@icon@icon\endcsname
\else
\makebox[\atfi@appearancewidth]{}%
\fi
\endgroup
}
% \end{macrocode}
% \end{macro}
%
% \begin{macrocode}
%</package>
% \end{macrocode}
%
% \subsection{Drivers}
%
% \subsubsection{\pdfTeX}
%
% \begin{macrocode}
%<*pdftex>
\NeedsTeXFormat{LaTeX2e}
\ProvidesFile{atfi-pdftex.def}%
[2010/09/27 v2.6 attachfile2 driver for pdfTeX (HO)]%
% \end{macrocode}
%
% \paragraph{\LuaTeX}
%
% \begin{macrocode}
\ifluatex
\ifnum\luatexversion<39 %
\else
\begingroup
\escapechar=-1 %
\def\atfi@temp#1{%
\ltx@IfUndefined{\string#1}{%
\let#1\ltx@undefined
\directlua{%
if tex.enableprimitives then %
tex.enableprimitives('', {'\string#1'})%
end%
}%
\ltx@ifundefined{\string#1}{%
}{%
\global#1=#1%
\@PackageInfoNoLine{attachfile2}{%
\string#1 enabled%
}%
}%
}{}%
}%
\atfi@temp\pdfliteral
\atfi@temp\pdfobj
\atfi@temp\pdflastobj
\atfi@temp\pdfxform
\atfi@temp\pdflastxform
\atfi@temp\pdfrefxform
\atfi@temp\pdfannot
\endgroup
\fi
\fi
% \end{macrocode}
%
% \paragraph{Macros for graphics data}
%
% \begin{macro}{\atfi@literal}
% \begin{macrocode}
\let\atfi@literal\pdfliteral
% \end{macrocode}
% \end{macro}
%
% \begin{macrocode}
\def\atfi@GSAVE{q }
\def\atfi@GRESTORE{Q }
\def\atfi@SETLINEWIDTH{w }
\def\atfi@LINETO{l }
\def\atfi@MOVETO{m }
\def\atfi@STROKE{S }
\def\atfi@FILL{f }
% \atfi@FILLSTROKE{<fill color>}{<stroke color>}
\def\atfi@FILLSTROKE#1#2{#1#2B }
% \end{macrocode}
% color: uppercase are stroke colors, lowercase non-stroke (fill) colors
% PS, however, does not different between stroke and not-stroke colors
% \begin{macrocode}
\def\atfi@SETRGBCOLORSTROKE{RG }
\def\atfi@SETRGBCOLORFILL{rg }
\def\atfi@SETGRAYSTROKE{G }
\def\atfi@SETGRAYFILL{g }
\def\atfi@SETCMYKCOLORSTROKE{K }
\def\atfi@SETCMYKCOLORFILL{k }
\def\atfi@RECTFILL{re f }
\def\atfi@RECTSTROKEFILL#1#2#3{#1#2#3re B }
\def\atfi@SETMITERLIMIT{M }
\def\atfi@SETFLAT{i }
\def\atfi@SETLINECAP{J }
\def\atfi@CURVETO{c }
\def\atfi@CURVETOV{v }
\def\atfi@CURVETOY{y }
\def\atfi@CLOSEPATH{h }
\def\atfi@SETLINEJOIN{j }
% \end{macrocode}
%
% \paragraph{File embedding}
%
% \begin{macrocode}
\define@key{AtFi@file}{Size}{%
\edef\atfi@params{\atfi@params/Size #1}%
}
% \end{macrocode}
% \begin{macro}{\atfi@embedfile}
% \begin{macrocode}
\def\atfi@embedfile#1{%
\ltx@IfUndefined{atfi@fileobj@#1}{%
\begingroup
\let\atfi@params\ltx@empty
\expandafter\let\expandafter\atfi@temp
\csname atfi@file@#1\endcsname
\ifx\atfi@temp\ltx@empty
\let\atfi@temp\relax
\fi
\ifx\atfi@temp\relax
\atfi@pdftexdata{#1}%
\else
\edef\x{%
\noexpand\setkeys{AtFi@file}{\@nameuse{atfi@file@#1}}%
}%
\x
\fi
\ifx\atfi@params\ltx@empty
\else
\edef\atfi@params{/Params<<\atfi@params>>}%
\fi
\immediate\pdfobj stream attr {%
/Type/EmbeddedFile%
\atfi@mimetype
\atfi@params
} file {#1}%
\expandafter
\xdef\csname atfi@fileobj@#1\endcsname{\the\pdflastobj}%
\endgroup
}{%
% file already embedded
}%
}
% \end{macrocode}
% \end{macro}
%
% \paragraph{Annotation appearance}
%
% \begin{macro}{\atfi@xform}
% input: \cs{atfi@appearancebox}, output: \cs{atfi@appearanceobj}
% \begin{macrocode}
\def\atfi@xform{%
\immediate\pdfxform\atfi@appearancebox
\edef\atfi@appearanceobj{\the\pdflastxform}%
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\atfi@xform@icon}
% \begin{macrocode}
\let\atfi@xform@icon\atfi@xform
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\atfi@refxform}
% \begin{macrocode}
\def\atfi@refxform#1{%
\pdfrefxform#1\relax
}
% \end{macrocode}
% \end{macro}
%
% \paragraph{File attachment annotation}
%
% \begin{macro}{\atfi@insert@file@annot}
% \begin{macrocode}
\def\atfi@insert@file@annot#1{%
\rule{0pt}{0pt}%
\ifatfi@appearance
\def\atfi@appearance@dict{%
/AP<<%
/N \atfi@appearanceobj\space 0 R%
/R \atfi@appearanceobj\space 0 R%
/D \atfi@appearanceobj\space 0 R%
>>%
}%
\else
\let\atfi@appearance@dict\ltx@empty
\fi
\ltx@IfUndefined{atfi@fsobj@#1}{%
\begingroup
\hypersetup{unicode=false}%
\atfi@pdfstringdef\atfi@file{#1}%
\immediate\pdfobj{%
<<%
/Type/Filespec%
/F(\atfi@file)%
\ifx\atfi@ucfilespec\ltx@empty
\else
/UF(\atfi@ucfilespec)%
\fi
/EF<<%
/F \@nameuse{atfi@fileobj@#1} 0 R%
>>%
>>%
}%
\expandafter\xdef\csname atfi@fsobj@#1\endcsname{%
\the\pdflastobj
}%
\endgroup
}{%
}%
\pdfannot width \atfi@scale\atfi@appearancewidth
height \atfi@scale\atfi@appearanceheight
depth \atfi@scale\atfi@appearancedepth {%
/Subtype/FileAttachment%
\atfi@icon
\atfi@color@annot
\atfi@author
\atfi@date
\atfi@annotname
\atfi@description
\atfi@subject
\atfi@appearance@dict
/F \theatfi@flags
/FS \@nameuse{atfi@fsobj@#1} 0 R%
}%
\rule{0pt}{\atfi@appearanceheight}%
\rule[-\atfi@appearancedepth]{0pt}{\atfi@appearancedepth}%
\rule{\atfi@appearancewidth}{0pt}%
}
% \end{macrocode}
% \end{macro}
%
% \begin{macrocode}
%</pdftex>
% \end{macrocode}
%
% \subsubsection{dvips}
%
% \begin{macrocode}
%<*dvips>
\NeedsTeXFormat{LaTeX2e}
\ProvidesFile{atfi-dvips.def}%
[2010/09/27 v2.6 attachfile2 driver for dvips (HO)]%
% \end{macrocode}
%
% \paragraph{Macros for graphics data}
%
% \begin{macro}{\atfi@literal}
% \begin{macrocode}
\def\atfi@literal#1{%
\special{ps:atfi_dict begin{#1}atfi_?pdfmark end}%
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\atfi@header}
% \begin{macrocode}
\def\atfi@header#1{%
\special{! #1}%
}
% \end{macrocode}
% \end{macro}
%
% \begin{macrocode}
\atfi@header{%
userdict begin 20 dict dup /atfi_dict exch def end begin%
/atfi_?pdfmark systemdict %
dup/pdfmark known%
{%
/exec get def%
}{%
/pop get def%
} ifelse%
{%
%
% x y width height atfi_re ->
languagelevel 2 ge {%
/atfi_rectfill { rectfill } bind def%
/atfi_rectstroke { rectstroke } bind def%
}{%
/atfi_rect {%
/atfi_height exch def%
/atfi_width exch def%
/atfi_x exch def%
/atfi_y exch def %
newpath %
atfi_x atfi_y moveto %
atfi_x atfi_width add atfi_y lineto %
atfi_x atfi_width add atfi_y atfi_height add lineto %
atfi_x atfi_y atfi_height add lineto %
closepath%
} bind def%
/atfi_rectfill {%
atfi_rect fill%
} bind def%
/atfi_rectstroke {%
atfi_rect stroke%
} bind def%
} ifelse%
/atfi_curveto_v {%
currentpoint 6 2 roll curveto%
} bind def%
/atfi_curveto_y {%
2 copy curveto%
} bind def%
%
% help macro for atfi_convert_date
/atfi_two {%
dup 10 lt%
{%
1 string cvs %
exch 1 add exch%
}{%
2 string cvs%
} ifelse %
putinterval%
} bind def%
%
% <seconds since 1970-01-01> atfi_convert_date -> (D:...Z)
/atfi_convert_date {%
dup%
/atfi_days exch 3600 idiv 24 idiv def%
% calc date part
/atfi_year 1970 def%
{%
atfi_year 400 mod 0 eq %
atfi_year 100 mod 0 ne %
atfi_year 4 mod 0 eq %
and or%
{366} {365} ifelse %
dup atfi_days lt%
{%
atfi_days exch sub /atfi_days exch def%
/atfi_year atfi_year 1 add def%
}{%
exit%
} ifelse%
} loop%
/atfi_month 1 def%
/atfi_days atfi_days 1 add def %
31 atfi_days lt%
{%
atfi_days 31 sub /atfi_days exch def%
/atfi_month atfi_month 1 add def %
366 eq {29} {28} ifelse dup atfi_days lt%
{%
atfi_days exch sub /atfi_days exch def%
/atfi_month atfi_month 1 add def %
31 atfi_days lt%
{%
atfi_days 31 sub /atfi_days exch def%
/atfi_month atfi_month 1 add def %
30 atfi_days lt%
{%
atfi_days 30 sub /atfi_days exch def%
/atfi_month atfi_month 1 add def %
31 atfi_days lt%
{%
atfi_days 31 sub /atfi_days exch def%
/atfi_month atfi_month 1 add def %
30 atfi_days lt%
{%
atfi_days 30 sub /atfi_days exch def%
/atfi_month atfi_month 1 add def %
31 atfi_days lt%
{%
atfi_days 31 sub /atfi_days exch def%
/atfi_month atfi_month 1 add def %
31 atfi_days lt%
{%
atfi_days 31 sub /atfi_days exch def%
/atfi_month atfi_month 1 add def %
30 atfi_days lt%
{%
atfi_days 30 sub /atfi_days exch def%
/atfi_month atfi_month 1 add def %
31 atfi_days lt%
{%
atfi_days 31 sub /atfi_days exch def%
/atfi_month atfi_month 1 add def %
30 atfi_days lt%
{%
atfi_days 30 sub /atfi_days exch def%
/atfi_month atfi_month 1 add def %
31 atfi_days lt%
{%
atfi_days 31 sub /atfi_days exch def%
/atfi_month atfi_month 1 add def%
} if%
} if%
} if%
} if%
} if%
} if%
} if%
} if%
} if%
} if%
} { pop } ifelse%
}{ pop } ifelse %
% calc time part
3600 24 mul mod %
dup 3600 idiv dup /atfi_hour exch def %
3600 mul sub %
dup 60 idiv dup /atfi_min exch def %
60 mul sub %
/atfi_sec exch def%
(D:19700101000000Z)%
dup 2 atfi_year 4 string cvs putinterval %
dup 6 atfi_month atfi_two %
dup 8 atfi_days atfi_two %
dup 10 atfi_hour atfi_two %
dup 12 atfi_min atfi_two %
dup 14 atfi_sec atfi_two%
} bind def %
%
% <filename> atfi_calc_checksum -> /CheckSum <checksum>
% or returns nothing, if MD5Encode is not given
false %
languagelevel 2 ge {%
(MD5Encode)%
{ pop true or }%
(MD5Encode) length string%
/Filter %
resourceforall%
} if%
{%
/atfi_calc_checksum {%
/atfi_checksum 16 string def%
/atfi_file exch (r) file def%
/atfi_md5sum atfi_checksum /MD5Encode filter def %
% not too efficient to read and write byte by byte,
% using a buffer is probably faster
atfi_size {%
atfi_file read%
{%
atfi_md5sum exch write%
} if%
} repeat %
atfi_md5sum closefile %
atfi_file closefile%
/CheckSum atfi_checksum%
} bind def%
}{%
/atfi_calc_checksum { pop } bind def%
} ifelse%
%
/atfi_pttobp { 72.27 div 72 mul } bind def%
/atfi_pdftodvipsx { 72.27 div Resolution mul } bind def%
/atfi_pdftodvipsy { 72.27 div VResolution mul } bind def%
%
} atfi_?pdfmark %
end%
}
% \end{macrocode}
% \begin{macrocode}
\def\atfi@GSAVE{gsave }
\def\atfi@GRESTORE{grestore }
\def\atfi@SETLINEWIDTH{setlinewidth }
\def\atfi@LINETO{lineto }
\def\atfi@MOVETO{moveto }
\def\atfi@STROKE{stroke }
\def\atfi@FILL{fill }
\def\atfi@FILLSTROKE#1#2{gsave #1 fill grestore #2 stroke }
\def\atfi@SETRGBCOLORSTROKE{setrgbcolor }
\def\atfi@SETRGBCOLORFILL{setrgbcolor }
\def\atfi@SETGRAYSTROKE{setgray }
\def\atfi@SETGRAYFILL{setgray }
\def\atfi@SETCMYKCOLORSTROKE{setcmykcolor }
\def\atfi@SETCMYKCOLORFILL{setcmykcolor }
\def\atfi@RECTFILL{atfi_rectfill }
\def\atfi@RECTSTROKEFILL#1#2#3{%
#3%
#1%
gsave atfi_rectfill grestore %
#2%
#3%
atfi_rectstroke %
#1%
}
\def\atfi@SETMITERLIMIT{setmiterlimit }
\def\atfi@SETFLAT{setflat }
\def\atfi@SETLINECAP{setlinecap }
\def\atfi@CURVETO{curveto }
\def\atfi@CURVETOV{atfi_curveto_v }
\def\atfi@CURVETOY{atfi_curveto_y }
\def\atfi@CLOSEPATH{closepath }
\def\atfi@SETLINEJOIN{setlinejoin }
% \end{macrocode}
%
% \begin{macrocode}
\newcounter{atfi@obj}
\renewcommand*{\theatfi@obj}{%
{atfi_obj_\number\c@atfi@obj}%
}
% \end{macrocode}
%
% \paragraph{File embedding}
%
% Most values for Params dictionary found in the \xext{atfi} file
% have priority:
% \begin{itemize}
% \item Recalculation (md5sum, \dots) is avoided.
% \item An external script has more possibilities than programming
% at PostScript level (operating system, getting the date and
% time values of the file with correct interpretation.
% \item Exception: status is called to test file existence, thus
% we get the value of size for free.
% \end{itemize}
% \begin{macrocode}
\define@key{AtFi@file}{Size}{}
% \end{macrocode}
% \begin{macro}{\atfi@embedfile}
% \begin{macrocode}
\def\atfi@embedfile#1{%
\ltx@IfUndefined{atfi@fileobj@#1}{%
\atfi@pdfstringdef\atfi@psfilename{#1}%
\stepcounter{atfi@obj}%
\expandafter\xdef\csname atfi@fileobj@#1\endcsname{\theatfi@obj}%
\begingroup
\let\atfi@params\ltx@empty
\expandafter\let\expandafter\atfi@temp
\csname atfi@file@#1\endcsname
\ifx\atfi@temp\ltx@empty
\let\atfi@temp\relax
\fi
\ifx\atfi@temp\relax
\atfi@pdftexdata{#1}%
\else
\edef\x{%
\noexpand\setkeys{AtFi@file}{\@nameuse{atfi@file@#1}}%
}%
\x
\fi
\atfi@literal{%
/atfi_filename(\atfi@psfilename)def %
atfi_filename status%
{%
% \end{macrocode}
% ok: file found\\
% save parameters of status command
% \begin{macrocode}
/atfi_created exch def%
/atfi_referenced exch def%
/atfi_size exch def %
pop %
% \end{macrocode}
%\begin{verbatim}
%drop parameter "pages" (storage space), never needed
%ghostscript:
% created: stat.st_ctime
% referenced: stat.st_mtime
% stat.st_ctime: interpretion depends on operating system:
% * unix: inode change time (not interesting)
% * win32: probably creation time
% --> /CreationDate
% stat.st_mtime: modification time --> /ModDate
% time values are seconds since 1970-01-01, GMT
%TODO: ghostscript offers "getenv" for getting the value
% of an environment variable. That could be used to
% to detect windows and settingthe /CreationDate entry.
%TODO: how are these values interpreted by other distiller
% programs?
%\end{verbatim}
% \begin{macrocode}
[%
/_objdef \theatfi@obj
/type/stream%
/OBJ pdfmark%
[%
\theatfi@obj
<<%
/Type/EmbeddedFile%
\atfi@mimetype
/Params%
<<%
\atfi@params
%
/Size atfi_size%
%
/product where%
{%
pop %
% \end{macrocode}
% check for ghostscript
% \begin{macrocode}
product (Ghostscript) search%
{%
pop pop pop %
% \end{macrocode}
% ghostscript is running
% \begin{macrocode}
\ifatfi@creationdate
\else
false % TODO: test for windows
{%
/CreationDate atfi_created atfi_convert_date%
} if%
\fi
\ifatfi@moddate
\else
/ModDate atfi_referenced atfi_convert_date%
\fi
} if%
% \end{macrocode}
% look for MD5Encode filter and calculate CheckSum
% \begin{macrocode}
} if %
\ifatfi@checksum
\else
atfi_filename atfi_calc_checksum%
\fi
>>%
>>%
/PUT pdfmark%
[%
\theatfi@obj
atfi_filename (r) file%
/PUT pdfmark%
[%
\theatfi@obj
/CLOSE pdfmark%
}{%
% \end{macrocode}
% error: file not found\\
% currently nothing is done
% \begin{macrocode}
} ifelse%
}%
\endgroup
}{%
% \end{macrocode}
% file already embedded
% \begin{macrocode}
}%
}
% \end{macrocode}
% \end{macro}
%
%
% \paragraph{Annotation appearance}
%
% output: \cs{atfi@appearanceobj}\\
% input: \cs{atfi@appearancebox}, \cs{atfi@icon@icon}
% \begin{macro}{atfi@xfrom@icon}
% \begin{macrocode}
\def\atfi@xform@icon{%
\stepcounter{atfi@obj}%
\edef\atfi@appearanceobj{\theatfi@obj}%
\atfi@literal{%
[%
/_objdef \atfi@appearanceobj
/BBox[%
0 %
0 %
\strip@pt\wd\atfi@appearancebox\space atfi_pttobp %
\strip@pt\dimexpr\dp\atfi@appearancebox
+\ht\atfi@appearancebox\relax\space atfi_pttobp%
]%
/BP pdfmark %
\csname atfi@acro\atfi@icon@icon @data\endcsname
[%
/EP pdfmark%
}%
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\atfi@xform}
% output: \cs{atfi@appearanceobj},
% input: \cs{atfi@appearancebox}
% \begin{macrocode}
\def\atfi@xform{%
\stepcounter{atfi@obj}%
\edef\atfi@appearanceobj{\theatfi@obj}%
\begingroup
\setbox\ltx@zero=\hbox{%
\atfi@literal{%
[%
/_objdef \atfi@appearanceobj
/BBox[%
currentpoint %
\strip@pt\dp\atfi@appearancebox\space sub %
currentpoint %
exch \strip@pt\wd\atfi@appearancebox\space add %
exch \strip@pt\ht\atfi@appearancebox\space add%
]%
/BP pdfmark %
gsave %
currentpoint %
2 copy translate %
72.27 Resolution div 72.27 VResolution div neg scale %
exch neg exch neg translate%
}%
\usebox{\atfi@appearancebox}%
\atfi@literal{%
grestore%
[%
/EP pdfmark%
}%
}%
% do not allocate any space for xobject definition
\dp\ltx@zero=\z@
\ht\ltx@zero=\z@
\wd\ltx@zero=\z@
\mbox{\usebox\ltx@zero}%
\endgroup
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\atfi@refxform}
% \begin{macrocode}
\def\atfi@refxform#1{%
\raisebox{-\atfi@appearancedepth}{%
\atfi@literal{%
gsave %
currentpoint translate %
Resolution 72 div VResolution neg 72 div scale%
[#1 /SP pdfmark % hash-ok
grestore%
}%
\makebox[\atfi@appearancewidth]{}%
}%
\rule{0pt}{\atfi@appearanceheight}%
}
% \end{macrocode}
% \end{macro}
%
% \paragraph{File attachment annotation}
%
% \begin{macro}{\atfi@insert@file@annot}
% \begin{macrocode}
\def\atfi@insert@file@annot#1{%
\rule{0pt}{0pt}%
\ifatfi@appearance
\def\atfi@appearance@dict{%
/AP<<%
/N \atfi@appearanceobj
/R \atfi@appearanceobj
/D \atfi@appearanceobj
>>%
}%
\else
\let\atfi@appearance@dict\ltx@empty
\fi
\ltx@IfUndefined{atfi@fsobj@#1}{%
\stepcounter{atfi@obj}%
\expandafter
\xdef\csname atfi@fsobj@#1\endcsname{\theatfi@obj}%
\begingroup
\hypersetup{unicode=false}%
\atfi@pdfstringdef\atfi@file{#1}%
\atfi@literal{%
[%
/_objdef \theatfi@obj
/type/dict%
/OBJ pdfmark%
[%
\theatfi@obj
<<%
/Type/Filespec%
/F(\atfi@file)%
\ifx\atfi@ucfilespec\ltx@empty
\else
/UF(\atfi@ucfilespec)%
\fi
/EF<<%
/F \csname atfi@fileobj@#1\endcsname
>>%
>>%
/PUT pdfmark%
}%
\endgroup
}{%
}%
\atfi@literal{%
[%
/Subtype/FileAttachment%
\atfi@icon
\atfi@color@annot
\atfi@author
\atfi@date
\atfi@annotname
\atfi@description
\atfi@subject
\atfi@appearance@dict
/F \theatfi@flags
/FS \csname atfi@fsobj@#1\endcsname
/Rect[%
currentpoint %
\strip@pt\dimexpr\atfi@scale\atfi@appearancedepth\relax
\space atfi_pdftodvipsy add %
currentpoint %
exch %
\strip@pt\dimexpr\atfi@scale\atfi@appearancewidth\relax
\space atfi_pdftodvipsx add %
exch %
\strip@pt\dimexpr\atfi@scale\atfi@appearanceheight\relax
\space atfi_pdftodvipsy sub %
]%
/ANN pdfmark%
}%
\rule{0pt}{\atfi@appearanceheight}%
\rule[-\atfi@appearancedepth]{0pt}{\atfi@appearancedepth}%
\rule{\atfi@appearancewidth}{0pt}%
}
% \end{macrocode}
% \end{macro}
%
% \begin{macrocode}
%</dvips>
% \end{macrocode}
%
% \subsubsection{dvipdfmx}
%
% \begin{macrocode}
%<*dvipdfmx>
\NeedsTeXFormat{LaTeX2e}
\ProvidesFile{atfi-dvipdfmx.def}%
[2010/09/27 v2.6 attachfile2 driver for dvipdfmx/XeTeX (HO)]%
% \end{macrocode}
%
% \paragraph{Macros for graphics data}
%
% \begin{macro}{\atfi@special}
% \begin{macrocode}
\def\atfi@special#1{%
\special{pdf:#1}%
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\atfi@literal}
% \begin{macrocode}
\def\atfi@literal#1{%
\atfi@special{content #1}%
}
% \end{macrocode}
% \end{macro}
%
% \begin{macrocode}
\def\atfi@GSAVE{q }
\def\atfi@GRESTORE{Q }
\def\atfi@SETLINEWIDTH{w }
\def\atfi@LINETO{l }
\def\atfi@MOVETO{m }
\def\atfi@STROKE{S }
\def\atfi@FILL{f }
\def\atfi@FILLSTROKE#1#2{#1#2B }
\def\atfi@SETRGBCOLORSTROKE{RG }
\def\atfi@SETRGBCOLORFILL{rg }
\def\atfi@SETGRAYSTROKE{G }
\def\atfi@SETGRAYFILL{g }
\def\atfi@SETCMYKCOLORSTROKE{K }
\def\atfi@SETCMYKCOLORFILL{k }
\def\atfi@RECTFILL{re f }
\def\atfi@RECTSTROKEFILL#1#2#3{#1#2#3re B }
\def\atfi@SETMITERLIMIT{M }
\def\atfi@SETFLAT{i }
\def\atfi@SETLINECAP{J }
\def\atfi@CURVETO{c }
\def\atfi@CURVETOV{v }
\def\atfi@CURVETOY{y }
\def\atfi@CLOSEPATH{h }
\def\atfi@SETLINEJOIN{j }
% \end{macrocode}
%
% \begin{macrocode}
\newcounter{atfi@obj}
\renewcommand*{\theatfi@obj}{%
@atfi_obj_\number\c@atfi@obj
}
% \end{macrocode}
%
% \paragraph{File embedding}
%
% \begin{macrocode}
\define@key{AtFi@file}{Size}{%
\edef\atfi@params{\atfi@params/Size #1}%
}
% \end{macrocode}
% \begin{macro}{\atfi@embedfile}
% \begin{macrocode}
\def\atfi@embedfile#1{%
\ltx@IfUndefined{atfi@fileobj@#1}{%
\stepcounter{atfi@obj}%
\begingroup
\let\atfi@params\ltx@empty
\expandafter\let\expandafter\atfi@temp
\csname atfi@file@#1\endcsname
\ifx\atfi@temp\ltx@empty
\let\atfi@temp\relax
\fi
\ifx\atfi@temp\relax
\atfi@pdftexdata{#1}%
\else
\edef\x{%
\noexpand\setkeys{AtFi@file}{\@nameuse{atfi@file@#1}}%
}%
\x
\fi
\ifx\atfi@params\ltx@empty
\else
\edef\atfi@params{/Params<<\atfi@params>>}%
\fi
\edef\atfi@FILE{#1}%
\filename@parse\atfi@FILE
\ifx\filename@area\ltx@empty
\edef\atfi@FILE{./\atfi@FILE}%
\fi
\EdefEscapeString\atfi@FILE{\atfi@FILE}%
\atfi@special{fstream %
\theatfi@obj
(\atfi@FILE)%
<<%
/Type/EmbeddedFile%
\atfi@mimetype
\atfi@params
>>%
}%
\atfi@special{close \theatfi@obj}%
\expandafter
\xdef\csname atfi@fileobj@#1\endcsname{\theatfi@obj}%
\endgroup
}{%
% file already embedded
}%
}
% \end{macrocode}
% \end{macro}
%
% \paragraph{Annotation appearance}
%
% \begin{macro}{\atfi@xform}
% input: \cs{atfi@appearancebox}, output: \cs{atfi@appearanceobj}
% \begin{macrocode}
\def\atfi@xform{%
\stepcounter{atfi@obj}%
\smash{%
\rlap{%
\atfi@special{bxobj \theatfi@obj\space
width \the\wd\atfi@appearancebox\space
height \the\ht\atfi@appearancebox\space
depth \the\dp\atfi@appearancebox
}%
\usebox\atfi@appearancebox
\atfi@special{exobj}%
}%
}%
\edef\atfi@appearanceobj{\theatfi@obj}%
}
% \end{macrocode}
% \end{macro}
% \begin{macro}{\atfi@xform@icon}
% \begin{macrocode}
\let\atfi@xform@icon\atfi@xform
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\atfi@refxform}
% \begin{macrocode}
\def\atfi@refxform#1{%
\leavevmode
\atfi@special{uxobj #1}%
}
% \end{macrocode}
% \end{macro}
%
% \paragraph{File attachment annotation}
%
% \begin{macro}{\atfi@insert@file@annot}
% \begin{macrocode}
\def\atfi@insert@file@annot#1{%
\rule{0pt}{0pt}%
\ifatfi@appearance
\def\atfi@appearance@dict{%
/AP<<%
/N \atfi@appearanceobj
/R \atfi@appearanceobj
/D \atfi@appearanceobj
>>%
}%
\else
\let\atfi@appearance@dict\ltx@empty
\fi
\ltx@IfUndefined{atfi@fsobj@#1}{%
\begingroup
\ifxetex
\let\atfi@temp\Hy@Warning
\let\Hy@Warning\ltx@gobble
\fi
\hypersetup{unicode=false}%
\ifxetex
\let\Hy@Warning\atfi@temp
\fi
\atfi@pdfstringdef\atfi@file{#1}%
\stepcounter{atfi@obj}%
\atfi@special{obj \theatfi@obj <<%
/Type/Filespec%
/F(\atfi@file)%
\ifx\atfi@ucfilespec\ltx@empty
\else
/UF(\atfi@ucfilespec)%
\fi
/EF<<%
/F \@nameuse{atfi@fileobj@#1}%
>>%
>>%
}%
\expandafter\xdef\csname atfi@fsobj@#1\endcsname{%
\theatfi@obj
}%
\endgroup
}{%
}%
\begingroup
\dimen@=\atfi@scale\atfi@appearancewidth
\edef\atfi@rule{width \the\dimen@}%
\dimen@=\atfi@scale\atfi@appearanceheight
\edef\atfi@rule{\atfi@rule\space height \the\dimen@}%
\dimen@=\atfi@scale\atfi@appearancedepth
\edef\atfi@rule{\atfi@rule\space depth \the\dimen@}%
\atfi@special{ann \atfi@rule
<<%
/Subtype/FileAttachment%
\atfi@icon
\atfi@color@annot
\atfi@author
\atfi@date
\atfi@annotname
\atfi@description
\atfi@subject
\atfi@appearance@dict
/F \theatfi@flags
/FS \@nameuse{atfi@fsobj@#1}%
>>%
}%
\endgroup
\rule{0pt}{\atfi@appearanceheight}%
\rule[-\atfi@appearancedepth]{0pt}{\atfi@appearancedepth}%
\rule{\atfi@appearancewidth}{0pt}%
}
% \end{macrocode}
% \end{macro}
%
%
% \begin{macrocode}
%</dvipdfmx>
% \end{macrocode}
%
% \subsection{Perl script \xfile{pdfatfi.pl}}
%
% \begin{macrocode}
%<*pdfatfi>
% \end{macrocode}
% \begingroup\small
% \SpecialEscapechar\|
% \begin{macrocode}
#!/usr/bin/env perl
use strict;
$^W=1; # turn warning on
#
# pdfatfi.pl
#
# Copyright (C) 2005-2010 Heiko Oberdiek.
#
# This work may be distributed and/or modified under the
# conditions of the LaTeX Project Public License, either
# version 1.3c of this license or (at your option) any later
# version. This version of this license is in
# http://www.latex-project.org/lppl/lppl-1-3c.txt
# and the latest version of this license is in
# http://www.latex-project.org/lppl.txt
# and version 1.3 or later is part of all distributions of
# LaTeX version 2005/12/01 or later.
#
# This work has the LPPL maintenance status "maintained".
#
# This Current Maintainer of this work is Heiko Oberdiek.
#
# See file "attachfile2.pdf" for a list of files that belong to
# this project.
#
# This file "pdfatfi.pl" may be renamed to "pdfatfi"
# for installation purposes.
#
my $file = "pdfatfi.pl";
my $program = uc($&) if $file =~ /^\w+/;
my $version = "2.6";
my $date = "2010/09/27";
my $author = "Heiko Oberdiek";
my $copyright = "Copyright (c) 2005-2010 by $author.";
#
# History:
# 2005/05/21 v1.0: First release.
# 2006/08/16 v2.2: Included in DTX file of attachfile2.dtx.
# 2010/09/27 v2.6: Keys ModDateTZ and CreationDateTZ added.
#
use POSIX qw(strftime); # %z is used (GNU)
use Digest::MD5;
### program identification
my $title = "$program $version, $date - $copyright\n";
### error strings
my $Error = "!!! Error:"; # error prefix
### variables
my $atfifile;
### option variables
my @bool = ("false", "true");
$::opt_help = 0;
$::opt_quiet = 0;
$::opt_debug = 0;
$::opt_verbose = 0;
my $usage = <<"END_OF_USAGE";
${title}Syntax: \L$program\E [options] <file[.atfi]>
Function: Help program for LaTeX package "attachfile2".
Options: (defaults:)
--help print usage
--(no)quiet suppress messages ($bool[$::opt_quiet])
--(no)verbose verbose printing ($bool[$::opt_verbose])
--(no)debug debug informations ($bool[$::opt_debug])
END_OF_USAGE
### process options
my @OrgArgv = @ARGV;
use Getopt::Long;
GetOptions(
"help!",
"quiet!",
"debug!",
"verbose!",
) or die $usage;
!$::opt_help or die $usage;
@ARGV == 1 or die "$usage$Error Missing jobname!\n";
$::opt_quiet = 0 if $::opt_verbose;
print $title unless $::opt_quiet;
### get jobname
$atfifile = $ARGV[0];
if (!-f $atfifile && -f "$atfifile.atfi") {
$atfifile .= ".atfi";
}
-f $atfifile or die "$Error File `$atfifile' not found!\n";
print "* job file = $atfifile\n" if $::opt_verbose;
if ($::opt_debug) {
print <<"END_DEB";
* OSNAME: $^O
* PERL_VERSION: $]
* ARGV: @OrgArgv
END_DEB
}
my $tmpfile = $atfifile . ".tmp";
my $timezone = strftime "%z", localtime;
sub gettz ($) {
my $time = shift;
my $tz = strftime "%z", localtime($time);
return '' unless $tz;
return 'Z' if $tz eq '+0000';
$tz =~ s/^([+\-]\d\d)(\d\d)$/$1'$2'/;
return $tz;
}
open(IN, $atfifile) or die "$Error Cannot open `$atfifile'!\n";
open(OUT, ">$tmpfile") or die "$Error Cannot write `$tmpfile'!\n";
while(<IN>) {
# timezone
if (s/^(\\attachfile\@timezone\{).*(\})$/$1$timezone$2/) {
print "* timezone = $timezone\n" if $::opt_verbose;
}
# file entry
if (/^\\attachfile\@file\[[^\]]*\]\{(.*)\}$/) {
my $hexfile = $1;
my $file = pack('H*', $hexfile);
my @s = stat($file);
if (@s == 0) {
print "!!! Warning: File `$file' not found!\n";
}
else {
my $size = @s[7];
my $mtime = @s[9];
my $ctime = @s[10]; # inode change time
my ($sec, $min, $hour, $mday, $mon, $year) =
localtime($mtime);
my $moddate = sprintf("%04d%02d%02d%02d%02d%02d",
$year + 1900, $mon + 1, $mday,
$hour, $min, $sec);
my $moddatetz = 'D:' . $moddate . gettz($mtime);
# Manual page "perlport" says that "ctime" is creation
# time instead of inode change time for "Win32" and
# "Mac OS", but it is unsupported for "Mac OS X".
my $creationdate = "";
my $creationdatetz = "";
if ($^O eq 'MSWin32') { # cygwin?
($sec, $min, $hour, $mday, $mon, $year) =
localtime($ctime);
$creationdate = sprintf("%04d%02d%02d%02d%02d%02d",
$year + 1900, $mon + 1, $mday,
$hour, $min, $sec);
$creationdatetz =
'D:' . $creationdate . gettz($ctime);
}
# md5 checksum
my $checksum = "";
my $ctx = Digest::MD5->new;
if (open(FILE, $file)) {
$ctx->addfile(*FILE);
$checksum = $ctx->hexdigest;
close(FILE);
}
else {
print "!!! Warning: File `$file' cannot be read,"
. " dropping checksum!\n";
}
$_ = "\\attachfile\@file["
. "ModDateTZ=$moddatetz"
. ",Size=$size"
. ($checksum ? ",CheckSum=$checksum" : "")
. ($creationdatetz ?
",CreationDateTZ=$creationdatetz" :
($creationdate ?
",CreationDate=$creationdate" : ""))
. "]{$hexfile}\n";
if ($::opt_verbose) {
print "* file entry = $file\n";
print " size = $size\n";
print " moddate = $moddate\n";
print " creationdate = $creationdate\n"
if $creationdate;
print " checksum = $checksum\n" if $checksum;
}
}
}
print OUT $_;
}
close(IN);
close(OUT);
unlink($atfifile) or die "$Error Cannot delete old `$atfifile'!\n";
rename $tmpfile, $atfifile
or die "$Error Cannot move `$tmpfile' to `$atfifile'!\n";
print "*** ready. ***\n" unless $::opt_quiet;
__END__
% \end{macrocode}
% \endgroup
% \begin{macrocode}
%</pdfatfi>
% \end{macrocode}
%
%
% \section{Installation}
%
% \subsection{Download}
%
% \paragraph{Package.} This package is available on
% CTAN\footnote{\url{ftp://ftp.ctan.org/tex-archive/}}:
% \begin{description}
% \item[\CTAN{macros/latex/contrib/oberdiek/attachfile2.dtx}] The source file.
% \item[\CTAN{macros/latex/contrib/oberdiek/attachfile2.pdf}] Documentation.
% \end{description}
%
%
% \paragraph{Bundle.} All the packages of the bundle `oberdiek'
% are also available in a TDS compliant ZIP archive. There
% the packages are already unpacked and the documentation files
% are generated. The files and directories obey the TDS standard.
% \begin{description}
% \item[\CTAN{install/macros/latex/contrib/oberdiek.tds.zip}]
% \end{description}
% \emph{TDS} refers to the standard ``A Directory Structure
% for \TeX\ Files'' (\CTAN{tds/tds.pdf}). Directories
% with \xfile{texmf} in their name are usually organized this way.
%
% \subsection{Bundle installation}
%
% \paragraph{Unpacking.} Unpack the \xfile{oberdiek.tds.zip} in the
% TDS tree (also known as \xfile{texmf} tree) of your choice.
% Example (linux):
% \begin{quote}
% |unzip oberdiek.tds.zip -d ~/texmf|
% \end{quote}
%
% \paragraph{Script installation.}
% Check the directory \xfile{TDS:scripts/oberdiek/} for
% scripts that need further installation steps.
% Package \xpackage{attachfile2} comes with the Perl script
% \xfile{pdfatfi.pl} that should be installed in such a way
% that it can be called as \texttt{pdfatfi}.
% Example (linux):
% \begin{quote}
% |chmod +x scripts/oberdiek/pdfatfi.pl|\\
% |cp scripts/oberdiek/pdfatfi.pl /usr/local/bin/|
% \end{quote}
%
% \subsection{Package installation}
%
% \paragraph{Unpacking.} The \xfile{.dtx} file is a self-extracting
% \docstrip\ archive. The files are extracted by running the
% \xfile{.dtx} through \plainTeX:
% \begin{quote}
% \verb|tex attachfile2.dtx|
% \end{quote}
%
% \paragraph{TDS.} Now the different files must be moved into
% the different directories in your installation TDS tree
% (also known as \xfile{texmf} tree):
% \begin{quote}
% \def\t{^^A
% \begin{tabular}{@{}>{\ttfamily}l@{ $\rightarrow$ }>{\ttfamily}l@{}}
% attachfile2.sty & tex/latex/oberdiek/attachfile2.sty\\
% atfi-dvips.def & tex/latex/oberdiek/atfi-dvips.def\\
% atfi-pdftex.def & tex/latex/oberdiek/atfi-pdftex.def\\
% atfi-dvipdfmx.def & tex/latex/oberdiek/atfi-dvipdfmx.def\\
% pdfatfi.pl & scripts/oberdiek/pdfatfi.pl\\
% attachfile2.pdf & doc/latex/oberdiek/attachfile2.pdf\\
% attachfile2.dtx & source/latex/oberdiek/attachfile2.dtx\\
% \end{tabular}^^A
% }^^A
% \sbox0{\t}^^A
% \ifdim\wd0>\linewidth
% \begingroup
% \advance\linewidth by\leftmargin
% \advance\linewidth by\rightmargin
% \edef\x{\endgroup
% \def\noexpand\lw{\the\linewidth}^^A
% }\x
% \def\lwbox{^^A
% \leavevmode
% \hbox to \linewidth{^^A
% \kern-\leftmargin\relax
% \hss
% \usebox0
% \hss
% \kern-\rightmargin\relax
% }^^A
% }^^A
% \ifdim\wd0>\lw
% \sbox0{\small\t}^^A
% \ifdim\wd0>\linewidth
% \ifdim\wd0>\lw
% \sbox0{\footnotesize\t}^^A
% \ifdim\wd0>\linewidth
% \ifdim\wd0>\lw
% \sbox0{\scriptsize\t}^^A
% \ifdim\wd0>\linewidth
% \ifdim\wd0>\lw
% \sbox0{\tiny\t}^^A
% \ifdim\wd0>\linewidth
% \lwbox
% \else
% \usebox0
% \fi
% \else
% \lwbox
% \fi
% \else
% \usebox0
% \fi
% \else
% \lwbox
% \fi
% \else
% \usebox0
% \fi
% \else
% \lwbox
% \fi
% \else
% \usebox0
% \fi
% \else
% \lwbox
% \fi
% \else
% \usebox0
% \fi
% \end{quote}
% If you have a \xfile{docstrip.cfg} that configures and enables \docstrip's
% TDS installing feature, then some files can already be in the right
% place, see the documentation of \docstrip.
%
% \subsection{Refresh file name databases}
%
% If your \TeX~distribution
% (\teTeX, \mikTeX, \dots) relies on file name databases, you must refresh
% these. For example, \teTeX\ users run \verb|texhash| or
% \verb|mktexlsr|.
%
% \subsection{Script installation}
% This package comes with a Perl script \xfile{pdfatfi.pl}.
% Install it somewhere so that it is executed, when it is called
% as \verb|pdfatfi| on the command line. Example for
% installing it under Linux:
% \begin{quote}
%\begin{verbatim}
%cp pdfatfi.pl /usr/local/bin/pdfatfi
%chmod +x /usr/local/bin/pdfatfi
%\end{verbatim}
% \end{quote}
%
%
% \subsection{Some details for the interested}
%
% \paragraph{Attached source.}
%
% The PDF documentation on CTAN also includes the
% \xfile{.dtx} source file. It can be extracted by
% AcrobatReader 6 or higher. Another option is \textsf{pdftk},
% e.g. unpack the file into the current directory:
% \begin{quote}
% \verb|pdftk attachfile2.pdf unpack_files output .|
% \end{quote}
%
% \paragraph{Unpacking with \LaTeX.}
% The \xfile{.dtx} chooses its action depending on the format:
% \begin{description}
% \item[\plainTeX:] Run \docstrip\ and extract the files.
% \item[\LaTeX:] Generate the documentation.
% \end{description}
% If you insist on using \LaTeX\ for \docstrip\ (really,
% \docstrip\ does not need \LaTeX), then inform the autodetect routine
% about your intention:
% \begin{quote}
% \verb|latex \let\install=y\input{attachfile2.dtx}|
% \end{quote}
% Do not forget to quote the argument according to the demands
% of your shell.
%
% \paragraph{Generating the documentation.}
% You can use both the \xfile{.dtx} or the \xfile{.drv} to generate
% the documentation. The process can be configured by the
% configuration file \xfile{ltxdoc.cfg}. For instance, put this
% line into this file, if you want to have A4 as paper format:
% \begin{quote}
% \verb|\PassOptionsToClass{a4paper}{article}|
% \end{quote}
% An example follows how to generate the
% documentation with pdf\LaTeX:
% \begin{quote}
%\begin{verbatim}
%pdflatex attachfile2.dtx
%makeindex -s gind.ist attachfile2.idx
%pdflatex attachfile2.dtx
%makeindex -s gind.ist attachfile2.idx
%pdflatex attachfile2.dtx
%\end{verbatim}
% \end{quote}
%
% \begin{thebibliography}{9}
% \bibitem{attachfile}
% Scott Pakin: \textit{The \xpackage{attachfile} package};
% 2005/02/20 v1.2;
% \CTAN{macros/latex/contrib/attachfile/}.
%
% \bibitem{embedfile}
% Heiko Oberdiek: \textit{The \xpackage{embedfile} package};
% 2006/08/16 v1.0;
% \CTAN{macros/latex/contrib/oberdiek/embedfile.pdf}.
%
% \bibitem{pdfspec}
% Adobe Systems Incorporated:
% \href{http://partners.adobe.com/public/developer/en/pdf/PDFReference16.pdf}%
% {\textit{PDF Reference, Fifth Edition, Version 1.6}},%
% November 2004;
% \url{http://partners.adobe.com/public/developer/pdf/index_reference.html}.
%
% \bibitem{mime}
% Network Working Group: RFC 2046, \textit{Multipurpose Internet Mail Extensions (MIME) Part Two:
% Media Types}, November 1996; \url{http://www.rfc-editor.org/}.
%
% \bibitem{types}
% IANA (Internet Assigned Numbers Authority):
% \textit{MIME Media Types}, May 2006;
% \url{http://www.iana.org/assignments/media-types/}.
%
% \end{thebibliography}
%
% \begin{History}
% \begin{Version}{2005/02/23 v2.0}
% \item
% New options: \xoption{draft}/\xoption{final}.
% \item
% New option scale for scaling the annotation rectangle.
% \item
% Supported driver options: \xoption{pdftex}, \xoption{dvips}.
% \item
% Configuration file `attachfile.cfg' supported.
% \item
% Dependency of package calc dropped.
% \item
% \eTeX\ (\cs{numexpr}, \cs{dimexpr}) used.
% \item
% New auxiliary file \cs{jobname.atfi} to get data unavailable
% by (pdf)\TeX, controlled by \cs{nofiles} and option nofiles.
% \item
% Use of package \xpackage{prokvopt} (never released).
% \end{Version}
% \begin{Version}{2005/10/07 v2.1}
% \item
% Option \xoption{annotname} for naming annotations
% (this name can be used for embedded go-to actions).
% \end{Version}
% \begin{Version}{2006/08/17 v2.2}
% \item
% Use of package \xpackage{kvoptions} instead of \xpackage{prokvopt}.
% \item
% DTX framework.
% \item
% A little documentation.
% \end{Version}
% \begin{Version}{2007/04/11 v2.3}
% \item
% Line ends sanitized.
% \end{Version}
% \begin{Version}{2008/07/29 v2.4}
% \item
% Improved color support. Option \xoption{color} now understands
% the usual color specifications if package \xpackage{xcolor} is
% loaded.
% \end{Version}
% \begin{Version}{2009/09/25 v2.5}
% \item
% New option \xoption{ucfilespec} (since PDF 1.7).
% \item
% Fix: \xpackage{hyperref}'s option \xoption{unicode} is disabled
% for file names except for \xoption{ucfilespec}.
% \end{Version}
% \begin{Version}{2010/09/27 v2.6}
% \item
% Support for dvipdfmx added, new option \xoption{dvipdfmx}
% and alias option \xoption{xetex}.
% (Thanks Will Robertson for pointing to |\special{pdf:fstream ...}|).
% \item
% New option \xoption{driverfallback}.
% \item
% All options except driver options are local options,
% that means they are ignored as global options.
% \item
% Some options are disabled after they are used
% (driver options, \xoption{draft}, \xoption{final}, \xoption{nofiles}).
% \item
% Driver files renamed from \texttt{atfi<driver>.def} to
% \texttt{atfi-<driver>.def}.
% \item
% Bug fix: \cs{textattachfile} now adds an entry into
% the \xext{atfi} file.
% \item
% Program pdfatfi.pl sets modification and creation time with
% time zone, because the time zone offset might differ with
% the file date.
% \end{Version}
% \end{History}
%
% \PrintIndex
%
% \Finale
\endinput
|