%%
%% 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'.
