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
|
% \iffalse meta-comment
%
% Copyright (C) 2006 by Scott Pakin <scott+hyxmp@pakin.org>
% -------------------------------------------------------
%
% This file may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3b
% of this license or (at your option) any later version.
% The latest version of this license is in:
%
% http://www.latex-project.org/lppl.txt
%
% and version 1.3b or later is part of all distributions of LaTeX
% version 2006/01/07 or later.
%
% \fi
%
% \iffalse
%<*driver>
\ProvidesFile{hyperxmp.dtx}
%</driver>
%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
%<package>\ProvidesPackage{hyperxmp}
%<*package>
[2006/05/21 v1.1 Store hyperref metadata in XMP format]
%</package>
%
%<*driver>
\documentclass{ltxdoc}
\usepackage{tocbibind}
\usepackage{hyperxmp}
\usepackage[bookmarksopen]{hyperref}
\EnableCrossrefs
\CodelineIndex
\RecordChanges
\begin{document}
\DocInput{hyperxmp.dtx}
\PrintChanges
\PrintIndex
\end{document}
%</driver>
% \fi
%
% \CheckSum{756}
%
% \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 \~}
%
%
% \changes{v1.0}{2006/05/14}{Initial version}
%
% \GetFileInfo{hyperxmp.dtx}
%
% \DoNotIndex{\#,\&,\<,\>,\\,\_,\|,\ }
% \DoNotIndex{\@cons,\@elt,\@empty,\@ifpackageloaded,\@ifundefined}
% \DoNotIndex{\@tempcnta,\@tempcntb}
% \DoNotIndex{\advance,\afterassignment,\aftergroup}
% \DoNotIndex{\begingroup,\bgroup}
% \DoNotIndex{\catcode}
% \DoNotIndex{\def,\divide}
% \DoNotIndex{\edef,\egroup,\else,\endgroup,\expandafter}
% \DoNotIndex{\fi,\futurelet}
% \DoNotIndex{\gdef,\global}
% \DoNotIndex{\if,\ifcase,\ifnum,\ifx,\immediate}
% \DoNotIndex{\let,\loop}
% \DoNotIndex{\MessageBreak,\multiply}
% \DoNotIndex{\newcommand,\noexpand}
% \DoNotIndex{\or}
% \DoNotIndex{\relax,\repeat}
% \DoNotIndex{\space,\string}
% \DoNotIndex{\the,\toks}
% \DoNotIndex{\xdef}
%
% ^^A Define a few logical styles.
% \DeclareRobustCommand{\term}[1]{#1\SortIndex{#1}{#1}}
% \DeclareRobustCommand{\pkgname}[1]{\textsf{#1}\SortIndex{#1}{\textsf{#1}}}
% \DeclareRobustCommand{\xmpterm}[1]{\textsf{#1}\SortIndex{#1}{\textsf{#1}}}
% \DeclareRobustCommand{\pdfterm}[1]{\textsf{#1}\SortIndex{#1}{\textsf{#1}}}
% \DeclareRobustCommand{\acrostyle}[1]{\textsc{\MakeLowercase{#1}}}
% \DeclareRobustCommand{\acro}[1]{^^A
% \acrostyle{#1}^^A
% \SortIndex{#1}{\acrostyle{#1}}^^A
% }
%
% ^^A Specify this document's metadata.
% \title{The \pkgname{hyperxmp} package\thanks{This document
% corresponds to \pkgname{hyperxmp}~\fileversion, dated \filedate.}}
% \author{Scott Pakin \\ \texttt{scott+hyxmp@pakin.org}}
% \hypersetup{%
% pdfauthor={Scott Pakin},
% pdftitle={The hyperxmp package},
% pdfsubject={LaTeX2e support for XMP metadata},
% pdfkeywords={LaTeX, embedded metadata, XMP, PDF, copyright, license, comments},
% pdfcopyright={Copyright (C) 2006, Scott Pakin},
% pdflicenseurl={http://www.latex-project.org/lppl/}
% }
%
% \maketitle
% \sloppy
%
% \begin{abstract}
% \pkgname{hyperxmp} makes it easy for an author to include \acro{XMP}
% metadata in a \acro{PDF} document produced by \LaTeX\@. \pkgname{hyperxmp}
% integrates seamlessly with \pkgname{hyperref} and requires virtually
% no modifications to a document that already specifies document
% metadata through \pkgname{hyperref}'s mechanisms.
% \end{abstract}
%
%
% \section{Introduction}
%
% Adobe Systems, Inc.\ has recently been promoting
% \acro{XMP}~\cite{Adobe2005:XMP}---eXtensible Metadata Platform---as a
% standard way to include metadata within a document. The idea behind
% \acro{XMP} is that it is an \acro{XML}-based description of various
% document attributes and is embedded as uncompressed, unencoded text
% within the document it describes. By storing the metadata this way it
% is independent of the document's file format. That is, regardless of
% whether a document is of \acro{PDF}, \acrostyle{JPEG},
% \acrostyle{HTML}, or any other type, it is trivial for a program (or
% human) to locate, extract, and---using any standard \acro{XML}
% parser---process the embedded \acro{XMP} metadata.
%
% As of this writing there are few tools that actually do process \acro{XMP}\@.
% However, it is easy to imagine future support existing in file
% browsers for displaying not only a document's filename but also its
% title, list of authors, description, and other metadata.
%
% \paragraph{This is too abstract! Give me an example.}
% Consider a \LaTeX\ document with three authors: Jack Napier, Edward
% Nigma, and Harvey Dent. The generated \acro{PDF} file will contain, among
% other information, the following stanza of \acro{XMP} code embedded within
% it:
%
% \begin{verbatim}
% <dc:creator>
% <rdf:Seq>
% <rdf:li>Jack Napier</rdf:li>
% <rdf:li>Edward Nigma</rdf:li>
% <rdf:li>Harvey Dent</rdf:li>
% </rdf:Seq>
% </dc:creator>
% \end{verbatim}
%
% In the preceding code, the |dc| namespace refers to the
% \href{http://purl.org/DC/}{Dublin Core schema}, a collection of
% metadata properties. The |dc:creator| property surrounds the list of
% authors. The |rdf| namespace is the
% \href{http://www.w3.org/RDF/}{Resource Description Framework}, which
% defines |rdf:Seq| as an ordered list of values. Each author is
% represented by an individual list item (|rdf:li|), making it easy for
% an \acro{XML} parser to separate the authors' names.
%
% Remember that \acro{XMP} code is stored as \emph{metadata}. It does not
% appear when viewing or printing the \acro{PDF} file. Rather, it is intended
% to make it easy for applications to identify and categorize the
% document.
%
% \paragraph{What metadata does \textsf{hyperxmp} process?}
% \pkgname{hyperxmp} knows how to embed each of the following types of
% metadata within a document:
%
% \begin{itemize}
% \item authors (|dc:creator|)
% \item copyright (|dc:rights|)
% \item date (|dc:date|)
% \item document identifier (|xapMM:DocumentID|)
% \item document instance identifier (|xapMM:InstanceID|)
% \item format (|dc:format|)
% \item keywords (|pdf:Keyword| and |dc:subject|)
% \item license \acro{URL} (|xapRights:WebStatement|)
% \item \acro{PDF}-generating tool (|pdf:Producer|)
% \item summary (|dc:description|)
% \item title (|dc:title|)
% \end{itemize}
%
% \noindent
% More types of metadata may be added in a future release.
%
% \paragraph{How does \textsf{hyperxmp} compare with the \textsf{xmpincl}
% package?}
% The short answer is that \pkgname{xmpincl} is more flexible but
% \pkgname{hyperxmp} is easier to use. With \pkgname{xmpincl}, the
% author manually constructs a file of arbitrary \acro{XMP} data and the
% package merely embeds it within the generated \acro{PDF} file. With
% \pkgname{hyperxmp}, the author specifies values for various predefined
% metadata types and the package formats those values as \acro{XMP} and embeds
% the result within the generated \acro{PDF} file.
%
% \pkgname{xmpincl} can embed \acro{XMP} only when running under pdf\LaTeX\ and
% only when in \acro{PDF}-generating mode. \pkgname{hyperxmp} additionally
% works with a few other \acro{PDF}-producing \LaTeX\ backends.
%
% \pkgname{hyperxmp} and \pkgname{xmpincl} can complement each other.
% An author may want to use \pkgname{hyperxmp} to produce a basic set of
% \acro{XMP} code, then extract the \acro{XMP} code from the \acro{PDF} file with a text
% editor, augment the \acro{XMP} code with any metadata not supported by
% \pkgname{hyperxmp}, and use \pkgname{xmpincl} to include the modified
% \acro{XMP} code in the \acro{PDF} file.
%
% \section{Usage}
%
% \pkgname{hyperxmp} provides no commands of its own. Rather, it
% processes some of the package options honored by \pkgname{hyperref}.
% To use \pkgname{hyperxmp}, merely put a |\usepackage{hyperxmp}|
% somewhere in your document's preamble. \pkgname{hyperxmp} will
% construct its \acro{XMP} data using the following \pkgname{hyperref} options:
%
% \begin{itemize}
% \item |pdfauthor|,
% \item |pdfkeywords|,
% \item |pdfproducer|,
% \item |pdfsubject|, and
% \item |pdftitle|.
% \end{itemize}
%
% \noindent
% \pkgname{hyperxmp} instructs \pkgname{hyperref} also to accept the
% following options, which have meaning only to \pkgname{hyperxmp}:
%
% \begin{itemize}
% \item |pdfcopyright| and
% \item |pdflicenseurl|.
% \end{itemize}
%
% \noindent
% |\pdfcopyright| defines the copyright text. |pdflicenseurl| defines a
% \acro{URL} that points to the document's license agreement.
%
% It's usually more convenient to provide values for those options using
% \pkgname{hyperref}'s |\hypersetup| command than on the |\usepackage|
% command line. See
% \href{ftp://tug.ctan.org/pub/tex-archive/macros/latex/contrib/hyperref/doc/manual.pdf}{the
% \pkgname{hyperref} manual} for more information. The following is a
% sample \LaTeX\ document that provides values for most of the metadata
% options that \pkgname{hyperxmp} recognizes:
%
% \begin{verbatim}
% \documentclass{article}
% \usepackage{hyperxmp}
% \usepackage{hyperref}
% \title{%
% On a heuristic viewpoint concerning the production and
% transformation of light}
% \author{Albert Einstein}
% \hypersetup{%
% pdftitle={%
% On a heuristic viewpoint concerning the production and
% transformation of light},
% pdfauthor={Albert Einstein},
% pdfcopyright={Copyright (C) 1905, Albert Einstein},
% pdfsubject={photoelectric effect},
% pdfkeywords={energy quanta, Hertz effect, quantum physics}
% }
% \begin{document}
% \maketitle
% A profound formal difference exists between the theoretical
% concepts that physicists have formed about gases and other
% ponderable bodies, and Maxwell's theory of electromagnetic
% processes in so-called empty space\dots
% \end{document}
% \end{verbatim}
%
% Compile the document to \acro{PDF} using any of the following approaches:
%
% \begin{itemize}
% \item pdf\LaTeX
% \item \LaTeX~$+$ Dvipdfm
% \item \LaTeX~$+$ Dvips~$+$ Ghostscript
% \end{itemize}
%
% The combination \LaTeX~$+$ Dvips~$+$ Adobe Acrobat Distiller
% \emph{almost} works but is hampered by a Distiller bug (at least in
% version~7.0.5) that incorrectly replaces the first author with the
% complete list of authors in the generated \acro{PDF} file. That is,
% if a document's authors are Jack Napier, Edward Nigma, and Harvey
% Dent, Distiller replaces ``Jack Napier'' with a single author named
% ``Jack Napier, Edward Nigma, Harvey Dent'' and leaves ``Edward Nigma''
% and ``Harvey Dent'' as the second and third authors, respectively.
% Until Adobe fixes this bug, Adobe Acrobat Distiller is not recommended
% for use with \pkgname{hyperxmp}.
%
% Besides the approaches listed above, other approaches may work as well
% but have not been tested. Note that in many \TeX\ distributions
% |ps2pdf| is a convenience script that calls Ghostscript with the
% appropriate options for converting PostScript to \acro{PDF} and
% |dvipdf| is a convenience script that calls |dvips| and |ps2pdf|; both
% |ps2pdf| and |dvipdf| should be compatible with \pkgname{hyperxmp}.
%
% \bigskip
%
% The resulting \acro{PDF} file will contain an \acro{XMP} packet that
% looks something like this:
%
% \begin{verbatim}
% <?xpacket begin="???" id="W5M0MpCehiHzreSzNTczkc9d"?>
% <x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="3.1-702">
% <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
% <rdf:Description rdf:about=""
% xmlns:pdf="http://ns.adobe.com/pdf/1.3/">
% <pdf:Keywords>energy quanta, Hertz effect,
% quantum physics</pdf:Keywords>
% <pdf:Producer>pdfeTeX-1.10b</pdf:Producer>
% </rdf:Description>
% <rdf:Description rdf:about=""
% xmlns:dc="http://purl.org/dc/elements/1.1/">
% <dc:format>application/pdf</dc:format>
% <dc:title>
% <rdf:Alt>
% <rdf:li xml:lang="x-default">On a heuristic viewpoint
% concerning the production and transformation of
% light</rdf:li>
% </rdf:Alt>
% </dc:title>
% <dc:description>
% <rdf:Alt>
% <rdf:li xml:lang="x-default">photoelectric effect</rdf:li>
% </rdf:Alt>
% </dc:description>
% <dc:rights>
% <rdf:Alt>
% <rdf:li xml:lang="x-default">Copyright (C) 1905,
% Albert Einstein</rdf:li>
% </rdf:Alt>
% </dc:rights>
% <dc:creator>
% <rdf:Seq>
% <rdf:li>Albert Einstein</rdf:li>
% </rdf:Seq>
% </dc:creator>
% <dc:subject>
% <rdf:Bag>
% <rdf:li>energy quanta</rdf:li>
% <rdf:li>Hertz effect</rdf:li>
% <rdf:li>quantum physics</rdf:li>
% </rdf:Bag>
% </dc:subject>
% <dc:date>
% <rdf:Seq>
% <rdf:li>2006-04-19</rdf:li>
% </rdf:Seq>
% </dc:date>
% </rdf:Description>
% <rdf:Description rdf:about=""
% xmlns:xapMM="http://ns.adobe.com/xap/1.0/mm/">
% <xapMM:DocumentID>uuid:c4188820-aef2-0a82-626ce4182b62</xapMM:DocumentID>
% <xapMM:InstanceID>uuid:9b62b67f-d754-626c-4c959595fd75</xapMM:InstanceID>
% </rdf:Description>
% </rdf:RDF>
% </x:xmpmeta>
% <?xpacket end="w"?>
% \end{verbatim}
%
% \pkgname{hyperxmp} splits the |pdfauthor| and |pdfkeywords| lists at
% commas. Therefore, when specifying |pdfauthor| and |pdfkeywords|, you
% should separate items with commas. Also, omit ``|and|'' and other
% text that does not belong to any list item. The following example
% should serve as clarification:
%
% \begin{description}
% \item[Wrong:] |pdfauthor={Jack Napier, Edward Nigma, and Harvey Dent}|
% \item[Wrong:] |pdfauthor={Jack Napier; Edward Nigma; Harvey Dent}|
% \item[Right:] |pdfauthor={Jack Napier, Edward Nigma, Harvey Dent}|
% \end{description}
%
% If you desperately need to include a comma within an author or keyword
% list you can define your own comma macro as follows:
%
% \begin{verbatim}
% \bgroup
% \catcode`,=11
% \gdef\mycomma{,}
% \egroup
% \end{verbatim}
%
% \noindent
% Thereafter, you can use |\mycomma| as a literal comma:
%
% \begin{verbatim}
% pdfauthor={Napier\mycomma\ Jack,
% Nigma\mycomma\ Edward,
% Dent\mycomma\ Harvey}
% \end{verbatim}
%
%
% \StopEventually{^^A
% \begin{thebibliography}{1}
% \bibitem{Adobe2004:PDF}
% Adobe Systems, Inc., San Jose, California.
% \newblock {\em {PDF} Reference, Fifth Edition: {A}dobe Portable Document Format
% Version~1.6}, November 2004.
% \newblock Available from
% \url{http://partners.adobe.com/public/developer/en/pdf/PDFReference16.pdf}.
%
% \bibitem{Adobe2005:pdfmark}
% Adobe Systems, Inc., San Jose, California.
% \newblock {\em {A}dobe {A}crobat~7.0.5 pdfmark Reference Manual}, October~2,
% 2005.
% \newblock Available from
% \url{http://partners.adobe.com/public/developer/en/acrobat/sdk/pdf/pdf_creation_apis_and_specs/pdfmarkReference.pdf}.
%
% \bibitem{Adobe2005:XMP}
% Adobe Systems, Inc., San Jose, California.
% \newblock {\em {XMP} Specification}, June 2005.
% \newblock Available from
% \url{http://partners.adobe.com/public/developer/en/xmp/sdk/xmpspecification.pdf}.
%
% \bibitem{Downes1994:ATB15}
% Michael Downes.
% \newblock Around the bend~\#15, answers, 4th (last) installment.
% \newblock \href{news:comp.text.tex}{\texttt{comp.text.tex}} newsgroup posting,
% January~3, 1994.
% \newblock Archived by Google at
% \url{http://groups.google.com/group/comp.text.tex/msg/7da7643b9e8f3b48}.
% \end{thebibliography}
% }
%
%
% \section{Implementation}
%
% This section presents the commented \LaTeXe\ source code for
% \pkgname{hyperxmp}. Read this section only if you want to learn how
% \pkgname{hyperxmp} is implemented.
%
%
% \subsection{Integration with \textsf{hyperref}}
%
% An important design decision underlying \pkgname{hyperxmp} is that the
% package should integrate seamlessly with \pkgname{hyperref}. To that
% end, \pkgname{hyperxmp} takes its \acro{XMP} metadata from the
% \pkgname{hyperref} |pdftitle|, |pdfauthor|, |pdfsubject|, and
% |pdfkeywords| options plus two new options, |pdfcopyright| and
% |pdflicenseurl|, introduced by \pkgname{hyperxmp}.
%
% \begin{macrocode}
\RequirePackage{keyval}
% \end{macrocode}
%
% \begin{macro}{\@pdfcopyright}
% Prepare to store the document's copyright statement. For consistency
% with \pkgname{hyperref}'s document-metadata naming conventions (which
% are in turn based on \LaTeXe's document-metadata naming conventions),
% we do not prefix the macro name with our package-specific |\hyxmp@|
% prefix.
% \begin{macrocode}
\def\@pdfcopyright{}
\define@key{Hyp}{pdfcopyright}{\pdfstringdef\@pdfcopyright{#1}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@pdflicenseurl}
% Prepare to store the \acro{URL} containing the document's license
% agreement. For consistency with \pkgname{hyperref}'s
% document-metadata naming conventions (which are in turn based on
% \LaTeXe's document-metadata naming conventions), we do not prefix the
% macro name with our package-specific |\hyxmp@| prefix.
% \begin{macrocode}
\def\@pdflicenseurl{}
\define@key{Hyp}{pdflicenseurl}{\pdfstringdef\@pdflicenseurl{#1}}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\hyxmp@find@metadata}
% Issue a warning message if the author failed to include any metadata
% at all.
% \begin{macrocode}
\newcommand*{\hyxmp@find@metadata}{%
\ifx\@pdfauthor\@empty
\ifx\@pdfcopyright\@empty
\ifx\@pdfkeywords\@empty
\ifx\@pdflicenseurl\@empty
\ifx\@pdfsubject\@empty
\ifx\@pdftitle\@empty
\PackageWarningNoLine{hyperxmp}{%
\jobname.tex did not specify any metadata to\MessageBreak
include in the XMP packet.\space\space Please see the hyperxmp\MessageBreak
documentation for instructions on how to provide\MessageBreak
metadata values to hyperxmp%
}%
\fi
\fi
\fi
\fi
\fi
\fi
}
% \end{macrocode}
% \end{macro}
%
% Rather than load \pkgname{hyperref} ourself we let the author do it
% then verify he actually did. This approach gives the author the
% flexibility to load \pkgname{hyperxmp} and \pkgname{hyperref} in
% either order and to call |\hypersetup| anywhere in the document's
% preamble, not just before \pkgname{hyperxmp} is loaded.
% \begin{macrocode}
\AtBeginDocument{%
\@ifpackageloaded{hyperref}%
{%
% \end{macrocode}
% We wait until the end of the document to construct the \acro{XMP}
% packet and write it to the \acro{PDF} document catalog. This gives
% the author ample opportunity to provide metadata to \pkgname{hyperref}
% and thereby \pkgname{hyperxmp}.
% \begin{macrocode}
\AtEndDocument{%
\hyxmp@find@metadata
\hyxmp@embed@packet
}%
}%
{\PackageWarningNoLine{hyperxmp}{%
\jobname.tex failed to include a\MessageBreak
\string\usepackage\string{hyperref\string}
in the preamble.\MessageBreak
Consequently, all hyperxmp functionality will be\MessageBreak
disabled}%
}%
}
% \end{macrocode}
%
%
% \subsection{Manipulating author-supplied data}
%
% The author provides metadata information to \pkgname{hyperxmp} via
% package options to \pkgname{hyperref} or via the \pkgname{hyperref}
% |\hypersetup| command. The functions in this section convert
% author-supplied lists (e.g.,~|pdfkeywords={foo, bar, baz}|) into
% \LaTeXe\ lists (e.g.,~|\@elt {foo}| |\@elt {bar}| |\@elt {baz}|) that
% can be more easily manipulated (Section~\ref{sec:list-manip}); define
% macros for the \acro{XML} entites |<|, |>|, and |&|
% (Section~\ref{sec:xml-entities}); trim spaces off the ends of strings
% (Section~\ref{sec:trim-spaces}); and, in Section~\ref{sec:text-xml},
% convert text to \acro{XML} (e.g.,~from |<scott+hyxmp@pakin.org>| to
% |<scott+hyxmp@pakin.org>|).
%
% \subsubsection{List manipulation}
% \label{sec:list-manip}
%
% We define a macro for converting a list of comma-separated elements
% (e.g.,~the list of \acro{PDF} keywords) to a list of \LaTeXe\
% |\@elt|-separated elements.
%
% \begin{macro}{\hyxmp@commas@to@list}
% Given a macro name~(|#1|) and a comma-separated list~(|#2|), define
% the macro name as the elements of the list, each preceded by |\@elt|.
% (Executing the macro therefore applies |\@elt| to each element in
% turn.)
% \begin{macrocode}
\newcommand*{\hyxmp@commas@to@list}[2]{%
\gdef#1{}%
\expandafter\hyxmp@commas@to@list@i\expandafter#1#2,,%
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\hyxmp@commas@to@list@i}
% \begin{macro}{\next}
% Recursively construct macro~|#1| from comma-separated list~|#2|. Stop
% if |#2| is empty.
% \begin{macrocode}
\def\hyxmp@commas@to@list@i#1#2,{%
\gdef\hyxmp@sublist{#2}%
\ifx\hyxmp@sublist\@empty
\let\next=\relax
\else
\hyxmp@trimspaces\hyxmp@sublist
\@cons{#1}{{\hyxmp@sublist}}%
\def\next{\hyxmp@commas@to@list@i{#1}}%
\fi
\next
}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \subsubsection{Character-code and XML entity definitions}
% \label{sec:xml-entities}
%
% The \pkgname{hyperref} package invokes |\pdfstringdef| on its metadata
% parameters, setting every character to \TeX\ category code~11
% (``other''). To match against these, we have to define a few category
% code~11 characters of our own. Furthermore, because \acro{XMP} is an
% \acro{XML} format, we have to replace the characters ``|&|'', ``|<|'',
% and ``|>|'' with equivalent \acro{XML} entities.
%
% \begin{macro}{\hyxmp@xml@amp}
% \begin{macro}{\hyxmp@other@amp}
% \begin{macro}{\hyxmp@amp}
% Define category code~11 (``other'') versions of the character~``|&|''
% and map |\hyxmp@other@amp| to its \acro{XML} entity, |&|.
% \begin{macrocode}
\bgroup
\catcode`\&=11
\gdef\hyxmp@xml@amp{&}
\global\let\hyxmp@other@amp=&
\gdef\hyxmp@amp{&}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\hyxmp@xml@lt}
% \begin{macro}{\hyxmp@other@lt}
% Define a category code~11 (``other'') version of the character~``|<|''
% and map |\hyxmp@other@lt| to its \acro{XML} entity, |<|.
% \begin{macrocode}
\catcode`\<=11
\gdef\hyxmp@xml@lt{<}
\global\let\hyxmp@other@lt=<
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\hyxmp@xml@gt}
% \begin{macro}{\hyxmp@other@gt}
% Define a category code~11 (``other'') version of the character~``|>|''
% and map |\hyxmp@other@gt| to its \acro{XML} entity, |>|.
% \begin{macrocode}
\catcode`\>=11
\gdef\hyxmp@xml@gt{>}
\global\let\hyxmp@other@gt=>
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\hyxmp@other@space}
% \begin{macro}{\next}
% Define a category code~11 (``other'') version of the space character.
% \begin{macrocode}
\def\next#1{#1}
\next{\global\let\hyxmp@other@space= } %
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\hyxmp@other@bs}
% Define a category code~11 (``other'') version of the character~``|\|''.
% \begin{macrocode}
\catcode`\|=0
\catcode`\\=11
|global|let|hyxmp@other@bs=\
|egroup
% \end{macrocode}
% \end{macro}
%
% \subsubsection{Trimming leading and trailing spaces}
% \label{sec:trim-spaces}
%
% To make it easier for \acro{XMP} processors to manipulate our output we
% define a |\hyxmp@trimspaces| macro to strip leading and trailing
% spaces from various data fields.
%
% \begin{macro}{\hyxmp@trimspaces}
% Redefine a macro as its previous value but without leading or trailing
% spaces. This code---as well as that for its helper macros,
% |\hyxmp@trimb| and |\hyxmp@trimc|---was taken almost verbatim from a
% solution to an \emph{Around the Bend} puzzle~\cite{Downes1994:ATB15}.
% Inline comments are also taken from the solution text.
% \begin{macrocode}
\catcode`\Q=3
% \end{macrocode}
% |\hyxmp@trimspaces\x| redefines |\x| to have the same replacement text
% sans leading and trailing space tokens.
% \begin{macrocode}
\newcommand{\hyxmp@trimspaces}[1]{%
% \end{macrocode}
% Use grouping to emulate a multi-token |afterassignment| queue.
% \begin{macrocode}
\begingroup
% \end{macrocode}
% Put |\toks 0 {| into the |afterassignment| queue.
% \begin{macrocode}
\aftergroup\toks\aftergroup0\aftergroup{%
% \end{macrocode}
% Apply |\hyxmp@trimb| to the replacement text of |#1|, adding a leading
% |\noexpand| to prevent brace stripping and to serve another purpose
% later.
% \begin{macrocode}
\expandafter\hyxmp@trimb\expandafter\noexpand#1Q Q}%
% \end{macrocode}
% Transfer the trimmed text back into |#1|.
% \begin{macrocode}
\edef#1{\the\toks0}%
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\hyxmp@trimb}
% |\hyxmp@trimb| removes a trailing space if present, then calls
% |\hyxmp@trimc| to clean up any leftover bizarre |Q|s, and trim a
% leading space. In order for |\hyxmp@trimc| to work properly we need to
% put back a |Q| first.
% \begin{macrocode}
\def\hyxmp@trimb#1 Q{\hyxmp@trimc#1Q}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\hyxmp@trimc}
% Execute |\vfuzz| assignment to remove leading space; the |\noexpand|
% will now prevent unwanted expansion of a macro or other expandable
% token at the beginning of the trimmed text. The |\endgroup| will feed
% in the |\aftergroup| tokens after the |\vfuzz| assignment is
% completed.
% \begin{macrocode}
\def\hyxmp@trimc#1Q#2{\afterassignment\endgroup \vfuzz\the\vfuzz#1}
\catcode`\Q=11
% \end{macrocode}
% \end{macro}
%
%
% \subsubsection{Converting text to XML}
% \label{sec:text-xml}
%
% The ``|<|'', ``|>|'', and ``|&|'' characters are significant to \acro{XML}.
% We therefore need to escape them in any author-supplied text.
%
% \begin{macro}{\hyxmp@xmlify}
% \begin{macro}{\hyxmp@xmlified}
% Given a piece of text defined using |\pdfstringdef| (i.e.,~with many
% special characters redefined to have category code~11), set
% |\hyxmp@xmlified| to the same text but with all occurrences of~``|<|''
% replaced with~|<|, all occurrences of~``|>|'' replaced with~|>|,
% and all occurrences of~``|&|'' replaced with~|&|.
%
% If |\pdfmark| is defined then there's a chance the user will run
% |dvips| on the resulting \acro{DVI} file and |dvips| may convert some
% of the spaces to newlines, which is problematic for the proper display
% of an \acro{XMP} packet. We therefore conditionally invoke
% |\hyxmp@obscure@spaces| to replace all spaces with | |.
% \begin{macrocode}
\newcommand*{\hyxmp@xmlify}[1]{%
\gdef\hyxmp@xmlified{}%
\expandafter\hyxmp@xmlify@i#1\@empty
\@ifundefined{pdfmark}{}{%
\expandafter\hyxmp@obscure@spaces\expandafter{\hyxmp@xmlified}%
}%
}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\hyxmp@xmlify@i}
% \begin{macro}{\hyxmp@one@token}
% Bind the next token in the input stream to |\hyxmp@one@token| and
% invoke |\hyxmp@xmlify@ii|. |\hyxmp@xmlify@i| (and therefore
% |\hyxmp@xmlify@ii|) is invoked on each character in the text supplied
% to |\hyxmp@xmlify|.
% \begin{macrocode}
\def\hyxmp@xmlify@i{\futurelet\hyxmp@one@token\hyxmp@xmlify@ii}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\hyxmp@xmlify@ii}
% \begin{macro}{\next}
% Given a token in |\hyxmp@one@token|, define |\next| to consume the
% token, append the corresponding text to |\hyxmp@xmlified|, and
% recursively invoke |\hyxmp@xmlify@i| to consume subsequent tokens.
% \begin{macrocode}
\def\hyxmp@xmlify@ii{%
\if\hyxmp@one@token\hyxmp@other@lt
% \end{macrocode}
% Replace ``|<|'' with |<|.
% \begin{macrocode}
\def\next##1{%
\xdef\hyxmp@xmlified{\hyxmp@xmlified\hyxmp@xml@lt}%
\hyxmp@xmlify@i
}%
\else
\if\hyxmp@one@token\hyxmp@other@gt
% \end{macrocode}
% Replace ``|>|'' with |>|.
% \begin{macrocode}
\def\next##1{%
\xdef\hyxmp@xmlified{\hyxmp@xmlified\hyxmp@xml@gt}%
\hyxmp@xmlify@i
}%
\else
\if\hyxmp@one@token\hyxmp@other@amp
% \end{macrocode}
% Replace ``|&|'' with |&|.
% \begin{macrocode}
\def\next##1{%
\xdef\hyxmp@xmlified{\hyxmp@xmlified\hyxmp@xml@amp}%
\hyxmp@xmlify@i
}%
\else
\ifx\hyxmp@one@token\hyxmp@other@space
% \end{macrocode}
% Store spaces. We need a special case for this to avoid inadvertently
% discarding spaces.
% \begin{macrocode}
\def\next##1{%
\g@addto@macro\hyxmp@xmlified{ }%
\hyxmp@xmlify@i##1%
}%
\else
\if\hyxmp@one@token\hyxmp@other@bs
% \end{macrocode}
% Replace |\|\meta{ooo} with |&#|\meta{ddd}|;|. For example, |\100|,
% the octal code for ``|@|'', is represented in \acro{XML} as~|@|.
% \begin{macrocode}
\def\next##1{\futurelet\hyxmp@one@token\hyxmp@xmlify@iii}
\else
\ifx\hyxmp@one@token\@empty
% \end{macrocode}
% End the recursion upon encountering |\@empty|.
% \begin{macrocode}
\def\next##1{}%
\else
% \end{macrocode}
% In most cases we merely append the next character in the input to
% |\hyxmp@xmlified| without any special processing.
% \begin{macrocode}
\def\next##1{%
\g@addto@macro\hyxmp@xmlified{##1}%
\hyxmp@xmlify@i
}%
\fi
\fi
\fi
\fi
\fi
\fi
% \end{macrocode}
% Recursively process the next character in the input stream.
% \begin{macrocode}
\next
}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\hyxmp@xmlify@iii}
% \begin{macro}{\next}
% \pkgname{hyperref}'s |\pdfstringdef| macro converts certain special
% characters to a backslash followed by a three-digit octal number.
% However, it also replaces ``|(|'' and ``|)|'' with ``|\(|'' and
% ``|\)|''. The |\hyxmp@xmlify@iii| macro is called after encountering
% (and removing) a backslash. If the next character in the input stream
% (|\hyxmp@one@token|) is a parenthesis, |\hyxmp@xmlify@iii| leaves it
% alone. Otherwise, |\hyxmp@xmlify@iii| assumes it's an octal number
% and replaces it with its \acro{XML} equivalent.
% \begin{macrocode}
\def\hyxmp@xmlify@iii{%
\def\next##1##2##3{%
\@tempcnta='##1##2##3
\xdef\hyxmp@xmlified{\hyxmp@xmlified
\hyxmp@amp\hyxmp@hash\the\@tempcnta;%
}%
\hyxmp@xmlify@i
}%
\if\hyxmp@one@token(
\let\next=\hyxmp@xmlify@i
\else
\if\hyxmp@one@token)
\let\next=\hyxmp@xmlify@i
\fi
\fi
\next
}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\hyxmp@obscure@spaces}
% The |dvips| backend rather obnoxiously word-wraps text. Doing so can
% cause \acro{XMP} metadata to be displayed incorrectly. For example,
% Adobe Acrobat displays the document's |dc:rights| (copyright notice)
% within a single-line field. By introducing an extra line break in the
% middle of the copyright notice, |dvips| implicitly causes it to be
% truncated when displayed.
%
% To thwart |dvips|'s word-wrapping, we define |\hyxmp@obscure@spaces|
% to replace each space in a given piece of text with an \acro{XML} | |
% (space) entity.
% \begin{macrocode}
\newcommand*{\hyxmp@obscure@spaces}[1]{%
\gdef\hyxmp@xmlified{}%
\expandafter\hyxmp@obscure@spaces@i#1 {} %
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\hyxmp@obscure@spaces@i}
% \begin{macro}{\hyxmp@one@token}
% \begin{macro}{\next}
% Do all of the work for |\hyxmp@obscure@spaces|.
% \begin{macrocode}
\def\hyxmp@obscure@spaces@i #1 #2 {%
\def\hyxmp@one@token{#2}%
\ifx\hyxmp@one@token\@empty
\xdef\hyxmp@xmlified{\hyxmp@xmlified#1}%
\let\next=\relax
\else
\xdef\hyxmp@xmlified{\hyxmp@xmlified#1\hyxmp@amp\hyxmp@hash32;}%
\def\next{\expandafter\hyxmp@obscure@spaces@i\expandafter#2 }%
\fi
\next
}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
%
% \subsection{UUID generation}
%
% We use a linear congruential generator to produce pseudorandom
% \acro{UUID}s. True, this method has its flaws but it's simple to
% implement in \TeX\ and is good enough for producing the \acro{XMP}
% \xmpterm{DocumentID} and \xmpterm{InstanceID} fields.
%
% \begin{macro}{\hyxmp@modulo@a}
% Replace the contents of |\@tempcnta| with the contents modulo~|#1|.
% Note that |\@tempcntb| is overwritten in the process.
% \begin{macrocode}
\def\hyxmp@modulo@a#1{%
\@tempcntb=\@tempcnta
\divide\@tempcntb by #1
\multiply\@tempcntb by #1
\advance\@tempcnta by -\@tempcntb
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\hyxmp@big@prime}
% \begin{macro}{\hyxmp@big@prime@ii}
% Define a couple of large prime numbers that can still be stored in a
% \TeX\ counter.
% \begin{macrocode}
\def\hyxmp@big@prime{536870923}
\def\hyxmp@big@prime@ii{536870027}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\hyxmp@seed@rng}
% \begin{macro}{\hyxmp@one@token}
% Seed \pkgname{hyperxmp}'s random-number generator from a given piece
% of text.
% \begin{macrocode}
\def\hyxmp@seed@rng#1{%
\@tempcnta=\hyxmp@big@prime
\futurelet\hyxmp@one@token\hyxmp@seed@rng@i#1\@empty
}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\hyxmp@seed@rng@i}
% \begin{macro}{\hyxmp@one@token}
% \begin{macro}{\next}
% Do all of the work for |\hyxmp@seed@rng|. For each character code $c$
% of the input text, assign $\mathtt{\string\@tempcnta} \leftarrow 3
% \cdot \mathtt{\string\@tempcnta} + c
% \pmod{\mathtt{\string\hyxmp@big@prime}}$.
% \begin{macrocode}
\def\hyxmp@seed@rng@i{%
\ifx\hyxmp@one@token\@empty
\let\next=\relax
\else
\def\next##1{%
\multiply\@tempcnta by 3
\advance\@tempcnta by `##1
\hyxmp@modulo@a{\hyxmp@big@prime}%
\futurelet\hyxmp@one@token\hyxmp@seed@rng@i
}%
\fi
\next
}
% \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\hyxmp@set@rand@num}
% \begin{macro}{\hyxmp@rand@num}
% Advance |\hyxmp@rand@num| to the next pseudorandom number in the
% sequence. Specifically, we assign $\mathtt{\string\hyxmp@rand@num}
% \leftarrow 3 \cdot \mathtt{\string\hyxmp@rand@num} +
% \mathtt{\string\hyxmp@big@prime@ii}
% \pmod{\mathtt{\string\hyxmp@big@prime}}$. Note that both |\@tempcnta|
% and |\@tempcntb| are overwritten in the process.
% \begin{macrocode}
\def\hyxmp@set@rand@num{%
\@tempcnta=\hyxmp@rand@num
\multiply\@tempcnta by 3
\advance\@tempcnta by \hyxmp@big@prime@ii
\hyxmp@modulo@a{\hyxmp@big@prime}%
\xdef\hyxmp@rand@num{\the\@tempcnta}%
}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\hyxmp@append@hex}
% Append a randomly selected hexadecimal digit to macro~|#1|. Note that
% both |\@tempcnta| and |\@tempcntb| are overwritten in the process.
% \begin{macrocode}
\def\hyxmp@append@hex#1{%
\hyxmp@set@rand@num
\@tempcnta=\hyxmp@rand@num
\hyxmp@modulo@a{16}%
\ifnum\@tempcnta<10
\xdef#1{#1\the\@tempcnta}%
\else
% \end{macrocode}
% There \emph{must} be a better way to handle the numbers~10--15 than
% with |\ifcase|.
% \begin{macrocode}
\advance\@tempcnta by -10
\ifcase\@tempcnta
\xdef#1{#1a}%
\or\xdef#1{#1b}%
\or\xdef#1{#1c}%
\or\xdef#1{#1d}%
\or\xdef#1{#1e}%
\or\xdef#1{#1f}%
\fi
\fi
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\hyxmp@append@hex@iv}
% Invoke |\hyxmp@append@hex| four times.
% \begin{macrocode}
\def\hyxmp@append@hex@iv#1{%
\hyxmp@append@hex#1%
\hyxmp@append@hex#1%
\hyxmp@append@hex#1%
\hyxmp@append@hex#1%
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\hyxmp@create@uuid}
% Define macro~|#1| as a \acro{UUID} of the form
% ``|uuid:|\textit{xxxxxxxx}|-|\textit{xxxx}|-|\textit{xxxx}|-|\textit{xxxxxxxxxxxx}''
% in which each ``\textit{x}'' is a lowercase hexadecimal digit. We
% assume that the random-number generator is already seeded. Note that
% |\hyxmp@create@uuid| overwrites both |\@tempcnta| and |\@tempcntb|.
% \begin{macrocode}
\def\hyxmp@create@uuid#1{%
\def#1{uuid:}%
\hyxmp@append@hex@iv#1%
\hyxmp@append@hex@iv#1%
\g@addto@macro#1{-}%
\hyxmp@append@hex@iv#1%
\g@addto@macro#1{-}%
\hyxmp@append@hex@iv#1%
\g@addto@macro#1{-}%
\hyxmp@append@hex@iv#1%
\hyxmp@append@hex@iv#1%
\hyxmp@append@hex@iv#1%
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\hyxmp@def@DocumentID}
% \begin{macro}{\hyxmp@DocumentID}
% Seed the random-number generator with a function of the current
% filename, \acro{PDF} document title, and \acro{PDF} author, then invoke
% |\hyxmp@create@uuid| to define |\hyxmp@DocumentID| as a random \acro{UUID}.
% \begin{macrocode}
\newcommand*{\hyxmp@def@DocumentID}{%
\edef\hyxmp@seed@string{\jobname:\@pdftitle:\@pdfauthor}%
\expandafter\hyxmp@seed@rng\expandafter{\hyxmp@seed@string}%
\edef\hyxmp@rand@num{\the\@tempcnta}%
\hyxmp@create@uuid\hyxmp@DocumentID
}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\hyxmp@def@InstanceID}
% \begin{macro}{\hyxmp@InstanceID}
% Seed the random-number generator with a function of the current
% filename, \acro{PDF} document title, \acro{PDF} author, and the
% current day, month, year, and minutes since midnight, then invoke
% |\hyxmp@create@uuid| to define |\hyxmp@InstanceID| as a random
% \acro{UUID}.
% \begin{macrocode}
\newcommand*{\hyxmp@def@InstanceID}{%
\edef\hyxmp@seed@string{%
\jobname:\@pdftitle:\@pdfauthor:%
\the\year/\the\month/\the\day:%
\the\time
}%
\expandafter\hyxmp@seed@rng\expandafter{\hyxmp@seed@string}%
\edef\hyxmp@rand@num{\the\@tempcnta}%
\hyxmp@create@uuid\hyxmp@InstanceID
}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \subsection{Constructing the XMP packet}
%
% An \acro{XMP} packet comprises a header, ``serialized \acro{XMP}'',
% padding, and a trailer~\cite{Adobe2005:XMP}. The serialized
% \acro{XMP} includes blocks of \acro{XML} for various \acro{XMP}
% schemata: Adobe \acro{PDF} (Section~\ref{sec:adobe-pdf}), Dublin Core
% (Section~\ref{sec:dublin-core}), \acro{XMP} Rights Management
% (Section~\ref{sec:xmp-rights}), and \acro{XMP} Media Management
% (Section~\ref{sec:xmp-media}). The |\hyxmp@construct@packet| macro
% constructs the \acro{XMP} packet into |\hyxmp@xml|. It first writes
% the appropriate \acro{XML} header, then calls the various
% schema-writing macros, then injects |\hyxmp@padding| as padding, and
% finally writes the appropriate \acro{XML} trailer.
%
% \subsubsection{XMP utility functions}
%
% \begin{macro}{\hyxmp@add@to@xml}
% Given a piece of text, replace all underscores with category-code~11
% (``other'') spaces and append the result to the |\hyxmp@xml| macro.
% \begin{macrocode}
\newcommand*{\hyxmp@add@to@xml}[1]{%
\bgroup
\@tempcnta=0
\loop
\lccode\@tempcnta=\@tempcnta
\advance\@tempcnta by 1
\ifnum\@tempcnta<256
\repeat
\lccode`\_=`\ \relax
\lowercase{\xdef\hyxmp@xml{\hyxmp@xml#1}}%
\egroup
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\hyxmp@hash}
% Define a category-code~11 (``other'') version of the ``|#|'' character.
% \begin{macrocode}
\bgroup
\catcode`\#=11
\gdef\hyxmp@hash{#}
\egroup
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\hyxmp@padding}
% \begin{macro}{\hyxmp@xml}
% The \acro{XMP} specification~\cite{Adobe2005:XMP} recommends leaving a
% few kilobytes of whitespace at the end of each \acro{XMP} packet to
% facilitate editing the packet in place. |\hyxmp@padding| is defined
% to contain 32~lines of 50~spaces and a newline apiece for a total of
% 1632 characters of whitespace.
% \begin{macrocode}
\bgroup
\xdef\hyxmp@xml{}%
\hyxmp@add@to@xml{%
__________________________________________________^^J%
}
\xdef\hyxmp@padding{\hyxmp@xml}%
\egroup
\xdef\hyxmp@padding{\hyxmp@padding\hyxmp@padding}
\xdef\hyxmp@padding{\hyxmp@padding\hyxmp@padding}
\xdef\hyxmp@padding{\hyxmp@padding\hyxmp@padding}
\xdef\hyxmp@padding{\hyxmp@padding\hyxmp@padding}
\xdef\hyxmp@padding{\hyxmp@padding\hyxmp@padding}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \begin{macro}{\hyxmp@today}
% Define today's date in \textit{YYYY}-\textit{MM}-\textit{DD} format.
% \begin{macrocode}
\xdef\hyxmp@today{\the\year}%
\ifnum\month<10
\xdef\hyxmp@today{\hyxmp@today-0\the\month}%
\else
\xdef\hyxmp@today{\hyxmp@today-\the\month}%
\fi
\ifnum\day<10
\xdef\hyxmp@today{\hyxmp@today-0\the\day}%
\else
\xdef\hyxmp@today{\hyxmp@today-\the\day}%
\fi
% \end{macrocode}
% \end{macro}
%
% \subsubsection{The Adobe PDF schema}
% \label{sec:adobe-pdf}
%
% \begin{macro}{\hyxmp@pdf@schema}
% Add properties defined by the Adobe \acro{PDF} schema to the |\hyxmp@xml|
% macro.
% \begin{macrocode}
\newcommand*{\hyxmp@pdf@schema}{%
% \end{macrocode}
% \begin{macro}{\hyxmp@have@any}
% Include an Adobe \acro{PDF} schema block if at least one of
% |\@pdfkeywords| and |\@pdfproducer| is defined.
% \begin{macrocode}
\let\hyxmp@have@any=!%
\ifx\@pdfkeywords\@empty
\ifx\@pdfproducer\@empty
\let\hyxmp@have@any=\@empty
\fi
\fi
\ifx\hyxmp@have@any\@empty
\else
% \end{macrocode}
% Add a block of \acro{XML} to |\hyxmp@xml| that lists the document's keywords
% (the \xmpterm{Keywords} property) and the tools used to produce the
% \acro{PDF} file (the \xmpterm{Producer} property).
% \begin{macrocode}
\hyxmp@add@to@xml{%
______<rdf:Description rdf:about=""^^J%
___________xmlns:pdf="http://ns.adobe.com/pdf/1.3/">^^J%
}%
\ifx\@pdfkeywords\@empty
\else
\hyxmp@xmlify{\@pdfkeywords}%
\hyxmp@add@to@xml{%
___________<pdf:Keywords>\hyxmp@xmlified</pdf:Keywords>^^J%
}%
\fi
\ifx\@pdfproducer\@empty
\else
\hyxmp@xmlify{\@pdfproducer}%
\hyxmp@add@to@xml{%
___________<pdf:Producer>\hyxmp@xmlified</pdf:Producer>^^J%
}%
\fi
\hyxmp@add@to@xml{%
______</rdf:Description>^^J%
}%
\fi
}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \subsubsection{The Dublin Core schema}
% \label{sec:dublin-core}
%
% \begin{macro}{\hyxmp@rdf@dc}
% Given a Dublin Core property~(|#1|) and a macro containing some
% |\pdfstringdef|-defined text~(|#2|), append the appropriate block of
% \acro{XML} to the |\hyxmp@xml| macro but only if |#2| is non-empty.
% \begin{macrocode}
\newcommand*{\hyxmp@rdf@dc}[2]{%
\ifx#2\@empty
\else
\hyxmp@xmlify{#2}%
\hyxmp@add@to@xml{%
_________<dc:#1>^^J%
____________<rdf:Alt>^^J%
_______________<rdf:li xml:lang="x-default">\hyxmp@xmlified</rdf:li>^^J%
____________</rdf:Alt>^^J%
_________</dc:#1>^^J%
}%
\fi%
}%
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\hyxmp@list@to@xml}
% Given a Dublin Core property~(|#1|), an RDF array~(|#2|), and a macro
% containing a comma-separated list~(|#3|), append the appropriate block
% of \acro{XML} to the |\hyxmp@xml| macro but only if |#3| is non-empty.
% \begin{macrocode}
\newcommand*{\hyxmp@list@to@xml}[3]{%
\ifx#3\@empty
\else
\hyxmp@add@to@xml{%
_________<dc:#1>^^J%
____________<rdf:#2>^^J%
}%
\bgroup
\hyxmp@commas@to@list\hyxmp@list{#3}%
\def\@elt##1{%
\hyxmp@xmlify{##1}%
\hyxmp@add@to@xml{%
_______________<rdf:li>\hyxmp@xmlified</rdf:li>^^J%
}%
}%
\hyxmp@list
\egroup
\hyxmp@add@to@xml{%
____________</rdf:#2>^^J%
_________</dc:#1>^^J%
}%
\fi
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\hyxmp@dc@schema}
% Add properties defined by the Dublin Core schema to the |\hyxmp@xml|
% macro. Specifically, we add entries for the \xmpterm{title} property
% if the author specified a |pdftitle|, the \xmpterm{description}
% property if the author specified a |pdfsubject|, the \xmpterm{rights}
% property if the author specified a |pdfcopyright|, the
% \xmpterm{creator} property if the author specified a |pdfauthor|, and
% the \xmpterm{subject} property if the author specified |pdfkeywords|.
% We also specify the \xmpterm{date} property using the date the
% document was run through \LaTeX.
% \begin{macrocode}
\newcommand*{\hyxmp@dc@schema}{%
\hyxmp@add@to@xml{%
______<rdf:Description rdf:about=""^^J%
____________xmlns:dc="http://purl.org/dc/elements/1.1/">^^J%
_________<dc:format>application/pdf</dc:format>^^J%
}%
\hyxmp@rdf@dc{title}{\@pdftitle}%
\hyxmp@rdf@dc{description}{\@pdfsubject}%
\hyxmp@rdf@dc{rights}{\@pdfcopyright}%
\hyxmp@list@to@xml{creator}{Seq}{\@pdfauthor}%
\hyxmp@list@to@xml{subject}{Bag}{\@pdfkeywords}%
\hyxmp@list@to@xml{date}{Seq}{\hyxmp@today}%
\hyxmp@add@to@xml{%
______</rdf:Description>^^J%
}%
}
% \end{macrocode}
% \end{macro}
%
% \subsubsection{The XMP Rights Management schema}
% \label{sec:xmp-rights}
%
% \begin{macro}{\hyxmp@xapRights@schema}
% Add properties defined by the XMP Rights Management schema to the
% |\hyxmp@xml| macro. Currently, these are only the \xmpterm{Marked}
% property and the \xmpterm{WebStatement} property and only if the
% author defined a |pdflicenseurl|.
% \begin{macrocode}
\newcommand*{\hyxmp@xapRights@schema}{%
\ifx\@pdflicenseurl\@empty
\else
\hyxmp@xmlify{\@pdflicenseurl}%
\hyxmp@add@to@xml{%
______<rdf:Description rdf:about=""^^J%
___________xmlns:xapRights="http://ns.adobe.com/xap/1.0/rights/">^^J%
_________<xapRights:Marked>True</xapRights:Marked>^^J%
_________<xapRights:WebStatement>\hyxmp@xmlified</xapRights:WebStatement>^^J%
______</rdf:Description>^^J%
}%
\fi
}
% \end{macrocode}
% \end{macro}
%
% \subsubsection{The XMP Media Management schema}
% \label{sec:xmp-media}
%
% \begin{macro}{\hyxmp@mm@schema}
% Add properties defined by the XMP Media Management schema to the
% |\hyxmp@xml| macro. Although the \xmpterm{DocumentID} property is
% defined in the \acro{XMP} specification~\cite{Adobe2005:XMP}, the
% \xmpterm{InstanceID} property is not. However, an
% \xmpterm{InstanceID} field is produced by Adobe Acrobat~7.0 (the
% latest version at the time of this writing) so it's probably worth
% including here.
% \begin{macrocode}
\gdef\hyxmp@mm@schema{%
\hyxmp@def@DocumentID
\hyxmp@def@InstanceID
\hyxmp@add@to@xml{%
______<rdf:Description rdf:about=""^^J%
____________xmlns:xapMM="http://ns.adobe.com/xap/1.0/mm/">^^J%
_________<xapMM:DocumentID>\hyxmp@DocumentID</xapMM:DocumentID>^^J%
_________<xapMM:InstanceID>\hyxmp@InstanceID</xapMM:InstanceID>^^J%
______</rdf:Description>^^J%
}%
}
% \end{macrocode}
% \end{macro}
%
% \subsubsection{Constructing the XMP packet}
%
% \begin{macro}{\hyxmp@construct@packet}
% \begin{macro}{\hyxmp@xml}
% Successively add \acro{XML} data to |\hyxmp@xml| until we have something we
% can insert into the document's \acro{PDF} catalog. The \acro{XMP}
% specification~\cite{Adobe2005:XMP} states that the argument to the
% \xmpterm{begin} attribute must be ``the Unicode `zero-width
% non-breaking space character'~(U+FEFF)''. However, Adobe Acrobat~7.0
% (the latest version at the time of this writing) inserts the sequence
% \meta{EF}\meta{BB}\meta{BF} so that's what we use here.
%
% We explicitly mark characters \meta{EF}, \meta{BB}, \meta{BF} as
% character code~12 (``letter'') because the \pkgname{inputenc} package
% re-encodes them as character code~13 (``active''), which causes
% \LaTeX\ to abort with an ``\texttt{Undefined control sequence}'' error
% upon invoking |\hyxmp@construct@packet|.
% \changes{v1.1}{2006/05/21}{Explicitly set the category codes of
% characters \string\meta{EF}, \string\meta{BB}, and
% \string\meta{BF} to ``letter''. Thanks to Daniel Sch\"omer for
% the bug report}
% \begin{macrocode}
\bgroup
\catcode`\^^ef=12
\catcode`\^^bb=12
\catcode`\^^bf=12
\gdef\hyxmp@construct@packet{%
\gdef\hyxmp@xml{}%
\hyxmp@add@to@xml{%
<?xpacket begin="^^ef^^bb^^bf" id="W5M0MpCehiHzreSzNTczkc9d"?>^^J%
<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="3.1-702">^^J%
___<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns\hyxmp@hash">^^J%
}%
\hyxmp@pdf@schema
\hyxmp@xapRights@schema
\hyxmp@dc@schema
\hyxmp@mm@schema
\hyxmp@add@to@xml{%
___</rdf:RDF>^^J%
</x:xmpmeta>^^J%
\hyxmp@padding
<?xpacket end="w"?>^^J%
}%
}
\egroup
% \end{macrocode}
% \end{macro}
% \end{macro}
%
%
% \subsection{Embedding the XMP packet}
%
% The \acro{PDF} specification~\cite{Adobe2004:PDF} says that ``a
% metadata stream can be attached to a document through the
% \pdfterm{Metadata} entry in the document catalog'' so that's what we
% do here. \pkgname{hyperxmp} does not currently support the embedding
% of \acro{XMP} in any format other than \acro{PDF}.
%
% \begin{macro}{\hyxmp@embed@packet}
% \begin{macro}{\hyxmp@driver}
% Determine which \pkgname{hyperref} driver is in use and invoke the
% appropriate embedding function.
% \begin{macrocode}
\newcommand*{\hyxmp@embed@packet}{%
\hyxmp@construct@packet
\def\hyxmp@driver{hpdftex}%
\ifx\hyxmp@driver\Hy@driver
\hyxmp@embed@packet@pdftex
\else
\def\hyxmp@driver{hdvipdfm}%
\ifx\hyxmp@driver\Hy@driver
\hyxmp@embed@packet@dvipdfm
\else
\@ifundefined{pdfmark}{%
\PackageWarningNoLine{hyperxmp}{%
Unrecognized hyperref driver `\Hy@driver'.\MessageBreak
\jobname.tex's XMP metadata will *not* be\MessageBreak
embedded in the resulting file}%
}{%
\hyxmp@embed@packet@pdfmark
}%
\fi
\fi
}
% \end{macrocode}
% \end{macro}
% \end{macro}
%
% \subsubsection{Embedding using pdf\TeX}
%
% \begin{macro}{\hyxmp@embed@packet@pdftex}
% Embed the \acro{XMP} packet using pdf\TeX\ primitives.
% \begin{macrocode}
\newcommand*{\hyxmp@embed@packet@pdftex}{%
\bgroup
\pdfcompresslevel=0
\immediate\pdfobj stream attr {%
/Type /Metadata
/Subtype /XML
}{\hyxmp@xml}%
\pdfcatalog {/Metadata \the\pdflastobj\space 0 R}%
\egroup
}
% \end{macrocode}
% \end{macro}
%
% \subsubsection{Embedding using any \texttt{pdfmark}-based backend}
%
% \begin{macro}{\hyxmp@embed@packet@pdfmark}
% Embed the \acro{XMP} packet using \pkgname{hyperref}'s |\pdfmark|
% command. I believe |\pdfmark| is used by the |dvipdf|, |dvipsone|,
% |dvips|, |dviwindo|, |nativepdf|, |pdfmark|, |ps2pdf| |textures|, and
% |vtexpdfmark| options to \pkgname{hyperref} but I've tested only a few
% of those.
% \begin{macrocode}
\newcommand*{\hyxmp@embed@packet@pdfmark}{%
\pdfmark{%
pdfmark=/OBJ,
Raw={/_objdef \string{hyxmp@Metadata\string} /type /stream}%
}%
\pdfmark{%
pdfmark=/PUT,
Raw={\string{hyxmp@Metadata\string}%
<<
/Type /Metadata
/Subtype /XML
>>
}%
}%
\pdfmark{%
pdfmark=/PUT,
Raw={\string{hyxmp@Metadata\string} (\hyxmp@xml)}%
}%
\pdfmark{%
pdfmark=/CLOSE,
Raw={\string{hyxmp@Metadata\string}}%
}%
% \end{macrocode}
% Adobe's |pdfmark| reference~\cite{Adobe2005:pdfmark} indicates that a
% metadata stream can be added to the document catalog by specifying the
% \pdfterm{Metadata} |pdfmark| instead of the \pdfterm{PUT} |pdfmark|.
% I see no advantage to this alternative mechanism and, furthermore, it
% works only with Adobe Acrobat Distiller and only with versions~6.0
% onwards. Consequently, \pkgname{hyperxmp} uses the traditional
% \pdfterm{PUT} mechanism to point the document catalog to our metadata
% stream.
% \begin{macrocode}
\pdfmark{%
pdfmark=/PUT,
Raw={\string{Catalog\string}%
<<
/Metadata \string{hyxmp@Metadata\string}%
>>
}%
}%
}
% \end{macrocode}
% \end{macro}
%
% \subsubsection{Embedding using \texttt{dvipdfm}}
%
% \begin{macro}{\hyxmp@embed@packet@dvipdfm}
% Embed the \acro{XMP} packet using a |dvipdfm|-specific |\special| command.
% Note that |dvipdfm| rather irritatingly requires us to count the
% number of characters in the |\hyxmp@xml| stream ourselves.
% \begin{macrocode}
\newcommand*{\hyxmp@embed@packet@dvipdfm}{%
\hyxmp@string@len{\hyxmp@xml}%
\special{pdf: object @hyxmp@Metadata
<<
/Type /Metadata
/Subtype /XML
/Length \the\@tempcnta
>>
stream^^J\hyxmp@xml endstream%
}%
\special{pdf: docview
<<
/Metadata @hyxmp@Metadata
>>
}%
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\hyxmp@string@len}
% Set |\@tempcnta| to the number of characters in a given string~(|#1|).
% The approach is first to tally the number of space characters then to
% tally the number of non-space characters. While this is rather
% sloppy I haven't found a better way to achieve the same effect,
% especially given that all of the characters in |#1| have already been
% assigned their category codes.
% \begin{macrocode}
\newcommand*{\hyxmp@string@len}[1]{%
\@tempcnta=0
\expandafter\hyxmp@count@spaces#1 {} %
\expandafter\hyxmp@count@non@spaces#1{}%
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\hyxmp@count@spaces}
% Count the number of spaces in a given string. We rely on the built-in
% pattern matching of \TeX's |\def| primitive to pry one word at a time
% off the head of the input string.
% \begin{macrocode}
\def\hyxmp@count@spaces#1 {%
\def\hyxmp@one@token{#1}%
\ifx\hyxmp@one@token\@empty
\advance\@tempcnta by -1
\else
\advance\@tempcnta by 1
\expandafter\hyxmp@count@spaces
\fi
}
% \end{macrocode}
% \end{macro}
%
% \begin{macro}{\hyxmp@count@non@spaces}
% Count the number of non-spaces in a given string. Ideally, we'd count
% both spaces and non-spaces but |\TeX| won't bind |#1| to a space
% character (category code~10). Hence, in each iteration, |#1| is bound
% to the next non-space character only.
% \begin{macrocode}
\newcommand*{\hyxmp@count@non@spaces}[1]{%
\def\hyxmp@one@token{#1}%
\ifx\hyxmp@one@token\@empty
\else
\advance\@tempcnta by 1
\expandafter\hyxmp@count@non@spaces
\fi
}
% \end{macrocode}
% \end{macro}
%
% \Finale
\endinput
|