-
Notifications
You must be signed in to change notification settings - Fork 0
/
xmpincl.sty
97 lines (97 loc) · 2.75 KB
/
xmpincl.sty
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
%%
%% This is file `xmpincl.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% xmpincl.dtx (with options: `package')
%%
%% This is a generated file.
%%
%% Copyright (C) 2005 by Maarten Sneep <sneep@nat.vu.nl>
%%
%% This work is licensed under the CC-GNU GPL, the human readable license
%% can be found here, with a link to the full text on this page.
%% http://creativecommons.org/licenses/GPL/2.0/
%%
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{xmpincl}
[2005/02/15 v2.1 Include XMP data in pdflatex]
\RequirePackage{ifpdf}
\ifpdf\else
\PackageWarningNoLine{xmpincl}%
{Only pdflatex is supported by the xmpincl package}
\newcommand{\includexmp}[1]{%
\PackageError{xmpincl}%
{latex is not supported by the \protect\includexmp\space package}%
{You tried to include XMP metadata in DVI production.\MessageBreak
That doesn't work, and I friendly tried to warn you.\MessageBreak
Just continue and pretend nothing is wrong,\MessageBreak
but please remove the package or switch to pdflatex.}
}
\relax\expandafter\endinput
\fi
\RequirePackage{ifthen}
\newcommand*{\mcs@xmpincl@patchFile}[1]{
\begingroup
\newwrite\xmpinclWrite
\newread\xmpinclRead
\immediate\openin\xmpinclRead #1.xmp
\immediate\openout\xmpinclWrite #1.xmpi
\newcommand{\mcs@xmpinclStart}%
{<?xpacket begin='' id='W5M0MpCehiHzreSzNTczkc9d'?> }
\newcommand{\mcs@xmpinclStartAlt}%
{<?xpacket begin='' id=''?> }
\newcommand{\mcs@xmpinclEnd}%
{<?xpacket end='r'?> }
\catcode`\#=12
\immediate\read\xmpinclRead to\xmpinclReadln%
\ifthenelse{%
\equal{\mcs@xmpinclStart}{\xmpinclReadln}%
\or%
\equal{\mcs@xmpinclStartAlt}{\xmpinclReadln}%
}%
{%
\immediate\write\xmpinclWrite{\mcs@xmpinclStart}%
}%
{%
\immediate\write\xmpinclWrite{\mcs@xmpinclStart}%
\immediate\write\xmpinclWrite{\xmpinclReadln}%
}%
\loop%
\immediate\read\xmpinclRead to\xmpinclReadln%
\ifthenelse{%
\equal{\mcs@xmpinclEnd}{\xmpinclReadln}%
}{% Note: no if.
}{%
\if\par\xmpinclReadln\else%
\immediate\write\xmpinclWrite{\xmpinclReadln}%
\fi%
}%
\ifeof\xmpinclRead\else%
\repeat
\immediate\write\xmpinclWrite{\mcs@xmpinclEnd}
\immediate\closein\xmpinclRead
\immediate\closeout\xmpinclWrite
\endgroup
}
\newcommand{\includexmp}[1]{%
\IfFileExists{#1.xmp}{
\mcs@xmpincl@patchFile{#1}
\begingroup
\pdfcompresslevel=0
\immediate\pdfobj stream attr {/Type /Metadata /Subtype /XML}
file{#1.xmpi}
\pdfcatalog{/Metadata \the\pdflastobj\space 0 R}
\endgroup
}
{\newcommand{\mcs@xmpincl@filename}{#1.xmp}
\PackageError{xmpincl}%
{The file \mcs@xmpincl@filename\space was not found}
{The file \mcs@xmpincl@filename\space The metadata file
wasn't found.\MessageBreak Oops.}
}
}
\endinput
%%
%% End of file `xmpincl.sty'.