% \iffalse meta-comment
%                                                                
%  File: pdfx.dtx
%
%  Copyright (c) 2016, CV Radhakrishnan <cvr@river-valley.org>,
%    Han The Thanh <thanh@river-valley.org>,
%    Ross Moore <ross.moore@mq.edu.au>,
%    Peter Selinger <selinger@mathstat.dal.ca>
%                      
%  This file may be distributed and/or modified under the conditions
%  of the LaTeX Project Public License, either version 1.2 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.2 or later is part of all distributions of LaTeX
%  version 1999/12/01 or later.
%
% \fi
%
% \CheckSum{2209}
% \iffalse
%
%<*driver>
\documentclass[a4paper]{ltxdoc}
\providecommand{\pdfxopt}{a-2u}
\usepackage{rvdtx}
\usepackage[\pdfxopt]{pdfx}
\usepackage[T1]{fontenc}
\hypersetup{citecolor=blue}
\EnableCrossrefs         
\CodelineIndex
\RecordChanges 
\begin{document}
  \DocInput{\jobname.dtx}
  \PrintChanges
  \PrintIndex
\end{document}
%</driver>
% \fi
%
% \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{pdfx.dtx}
%
% \DoNotIndex{\newcommand,\newenvironment}
% 
% \DoNotIndex{\def,\edef,\gdef,\xdef,\global,\long,\let}
% \DoNotIndex{\expandafter,\string,\the,\ifx,\else,\fi}
% \DoNotIndex{\csname,\endcsname,\relax,\begingroup,\endgroup}
% \DoNotIndex{\DeclareTextCommand,\DeclareTextCompositeCommand}
% \DoNotIndex{\space,\@empty,\special,\@nil,\advance\@nnil}
% \DoNotIndex{\\,\@gobble,\@@,\@fornoop,\@fortmp,\@ifundefined}
% \DoNotIndex{\@tempcnta,\@tempcntb,\{,\},\alph,\bgroup,\egroup}
% \DoNotIndex{\do,\end,\HN,\ifcase,\ifnum,\IfFileExists,\ifvmode}
% \DoNotIndex{\ignorespaces,\immediate,\input,\item,\jobname}
% \DoNotIndex{\leavevmode,\loop,\repeat,\makeatletter,\makeatother}
% \DoNotIndex{\meaning,\newcounter,\next,\or,\par,\renewcommand}
% \DoNotIndex{\renewcommand,\renewenvironment,\stepcounter}
% \DoNotIndex{\Tg,\thepage,\unskip,\write,\advance,\{,\}}
% \DoNotIndex{\@ifpackageloaded,\@pdfcreationdate,\@pdfcreator}
% \DoNotIndex{\@pdfmoddate,\AtBeginDocument,\catcode,\DeclareOption}
% \DoNotIndex{\endinput,\endlinechar,\errmessage,\everyeof,\futurelet}
% \DoNotIndex{\Hy@DisableOption,\Hy@UseMaketitleInfos,\hypersetup}
% \DoNotIndex{\inputencoding,\InputIfFileExists,\NeedsTeXFormat}
% \DoNotIndex{\newif,\noexpand,\obeyspaces,\PackageError,\PDF@FinishDoc}
% \DoNotIndex{\pdfcatalog,\pdfcreationdate,\pdfgeninterwordspace}
% \DoNotIndex{\pdfinterwordspace,\pdfinterwordspaceoff,\pdfgentounicode}
% \DoNotIndex{\pdfinfo,\pdfinterwordspaceon,\pdflastobj,\pdfmapline}
% \DoNotIndex{\pdfmdfivesum,\pdfminorversion,\pdfobj,\pdfobjcompresslevel}
% \DoNotIndex{\pdfpageattr,\pdfresetpageorigin,\pdfstringdef}
% \DoNotIndex{\pdftexbanner,\ProcessOptions,\ProvidesPackage,\RequirePackage}
% \DoNotIndex{\scantokens,\typeout}
%
% \changes{v1.00}{2008/12/01}{Initial commit to the CVS.}
% \changes{v1.01}{2008/12/10}{glyphtounicode-cmr.tex included with the
%   package.}
% \changes{v1.3}{2008/12/01}{Fix copyright in xmp files.}
% \changes{v1.5.4}{2015/02/28}{Fixed timezone bug; Unicode support; more
%   PDF variants; added color profiles.}
% \changes{v1.5.5}{2015/03/23}{Support for PDF/X-4p and PDF/X-5pg 
%   with external color profiles.}
% \changes{v1.5.6}{2016/02/05}{Suppressed `dummy-space' font warning;
%   removed spurious '?' in XMP packets; improved handling of Color Profiles;
%   ensure  Hy@pdfatrue  when building PDF/A, for link flags;
%   properly enables  xcolor  conversion of color models.}
%
% \title{Generation of PDF/X- and PDF/A-compliant PDFs
%  with pdf\TeX{} --- \texttt{pdfx.sty}}
% \date{2016/02/05}
% \version{1.5.6}
% \keywords{PDF, PDF/A, PDF/X, pdf\TeX, \LaTeX}
% \author{C.\,V.\,Radhakrishnan, \Thanh, Ross~Moore {\upshape\small
% and} Peter Selinger}
% \contact{\texttt{[cvr,thanh]@river-valley.org},
% \texttt{ross.moore@mq.edu.au}, \texttt{selinger@mathstat.dal.ca}}
% 
% \maketitle
%
% \StopEventually{}
%
% \section[Introduction]{Introduction}
%
% This package\footnote{A slightly earlier version of this documentation 
% was published as \cite{pdfx}.}
% currently supports generation of PDF/X- and 
% PDF/A-compliant documents using \pdftex, in some of their variants. 
% Support for additional standards, such as PDF/E, PDF/VT 
% is also available; see the complete list in Section~\ref{ssec-options} below. 
% By `supports', we mean that the package provides correct and sufficient  
% means to declare that a document conforms with a stated PDF variant
% (PDF/X, PDF/A, PDF/E, PDF/VT, etc.) along with the version 
% and/or level of conformance.
% This package also allows appropriate metadata and color profile
% to be specified, according to the requirements of the PDF variant.
%
% Metadata elements, most of which must ultimately be written as XML
% using the UTF-8 encoding, is provided via a file named |\jobname.xmpdata|,
% for the running \LaTeX\ job. Without such a file, providing some required
% information as well as a large range of optional data, a fully validating
% PDF file cannot be achieved. The PDF can be created, having the correct
% visual appearance on all pages, but it will not pass validation checks.
% Section~\ref{ssec-metadata} describes how this file should be constructed.
%
% \medskip
% What this package \emph{does not} do is to check for all the details
% of document structure and type of content that may be required
% (or restricted) within a PDF variant. For example, PDF/VT \cite{PDFVT} requires
% well-structure parts, using Form XObject sections tagged as `/DPart'.
% Similarly PDF/A-1a (and 2a and 3a) \cite{PDFA,PDFA2,PDFA3} require  
% a fully `Tagged PDF', including a detailed structure tagging which  
% envelops the complete contents of the document.
% This is beyond the current version of \pdftex, as commonly shipped.
% So while this package provides enough to meet the declaration,
% metadata and font-handling aspects for these PDF/A variants, 
% it is not sufficient to produce fully conforming PDFs. 
% However, with extra \pdftex-based software that \emph{is} capable 
% of producing `Tagged PDF', this package can be used as part of 
% the overall workflow to produce fully conforming documents.
% It is also reported to have been successfully used with Lua\TeX. 
%
%
% \subsection{PDF standards}\label{ssec-standards}
%
% PDF/X and PDF/A are umbrella terms used to denote several ISO
% standards \cite{PDFX,PDFX3,PDFX1a,PDFX4,PDFX5,PDFA,PDFA2,PDFA3} 
% that define different subsets of the PDF standard \cite{PDF17,ISO32000}. 
% The objective of PDF/X is to facilitate graphics exchange between
% document creator and printer and therefore, has all requirements
% related to printing. For instance, in PDF/X, all fonts need to be
% embedded and all images need to be CMYK or spot colors. PDF/X-2 and
% PDF/X-3 accept calibrated RGB and CIELAB colors along with all other
% specifications of PDF/X.
% Since 2005 other variants of PDF/X have emerged, as extra effects
% (such as layering and transparency) have been supported within the PDF
% standard itself. The full range of versions and conformance supported 
% in this package is discussed below in Section~\ref{ssec-options}.
%
% PDF/A defines a profile for archiving PDF documents, which ensures
% the documents can be reproduced in the exact same way in years to
% come. A key element to achieving this is that PDF/A documents
% are 100\% self-contained.  All the information needed to display the
% document in the same manner every time is embedded in the file. 
% A PDF/A document is not permitted to be reliant on information from
% external sources.  Other restrictions include avoidance of
% audio/video content, JavaScript and encryption.  
% Mandatory inclusion of fonts, color profile and standards-based metadata 
% are absolutely essential for PDF/A.
% Later versions allow for use of image compression and file attachments.
%
% PDF/E is an ISO standard \cite{PDFE} intended for documents used in engineering workflows. 
% PDF/VT \cite{PDFVT} allows for high-volume customised form printing, such as utility bills.
% PDF/UA (`Universal Accessibility') is emerging as a standard \cite{PDF-UA,PDFUA1} supporting 
% Assistive Technologies, incorporating web-accessibility guidelines (WCAG) 
% for electronic documents. 
% In future, PDF/H may emerge for health records and medical-related
% documents. Other applications can be envisaged. 
% Declarations and Metadata are supported for the first two of these.
% The others are the subject of further work; revised versions of this
% package can be expected in later years.
%
%
% \section[Usage]{Usage}
%
% The package can be loaded with the command:
% \begin{decl}
% \defmacro{usepackage}|[<option>]{pdfx}|
% \end{decl}
% where the options are as follows.
%
% \subsection{Options}\label{ssec-options}
%
% \subsubsection{PDF/A options}
% 
% PDF/A is an ISO standard~\cite{PDFA,PDFA2,PDFA3} intended for long-term archiving of
% electronic documents. It therefore emphasizes self-containedness and
% reproducibility, as well as machine-readable metadata.  The PDF/A
% standard has three conformance levels `a', `b', and `u'. Level
% `a' is the strictest, but is not yet fully implemented by the
% |pdfx| package. Conformance level `u' has the same requirements as
% level `b', but with the additional requirement that all text in
% the document must have a Unicode mapping. However, the |pdfx|
% package produces such Unicode mappings even in level `b' files.
% The standard also has three different versions 1, 2, and 3, which
% were standardized in 2005, 2011 and 2012, respectively.  Earlier
% versions contain a subset of the features of later versions, so for
% maximum portability, it is preferable to use a lower-numbered
% version. There is no conformance level `u' in version 1 of the
% standard.  For many typical uses of PDF/A, it is sufficient to use
% PDF/A-1b.
%
% \begin{itemize}
% \item |a-1a|: generate PDF/A-1a. Experimental, not fully implemented.
% \item |a-1b|: generate PDF/A-1b.
% \item |a-2a|: generate PDF/A-2a. Experimental, not fully implemented.
% \item |a-2b|: generate PDF/A-2b.
% \item |a-2u|: generate PDF/A-2u.
% \item |a-3a|: generate PDF/A-3a. Experimental, not fully implemented.
% \item |a-3b|: generate PDF/A-3b.
% \item |a-3u|: generate PDF/A-3u.
% \end{itemize}
% By `Experimental, not fully implemented' here we mean primarily that 
% the document structure, as required for `Tagged PDF', is not handled
% by this package. Using other \pdftex-based software that \emph{is} 
% capable of producing such complete tagging, conforming documents
% can indeed be produced.
%
% \subsubsection{PDF/E options}
% 
% PDF/E is an ISO standard intended for documents used in engineering
% workflows. There is only one version of the PDF/E standard so far,
% and it is called PDF/E-1.
% 
% \begin{itemize}
% \item |e-1|: generate PDF/E-1.
% \end{itemize}
%
% \subsubsection{PDF/VT options}
%
% PDF/VT is an ISO standard intended as an exchange format for
% variable and transactional printing, and is an extension of the
% PDF/X-4 standard. The standard specifies three PDF/VT conformance
% levels. Level 1 is for single-file exchange, level 2 is for
% multi-file exchange, and level 2s is for streamed delivery.
% Currently, none of the PDF/VT conformance levels are fully
% implemented by the |pdfx| package.
% 
% \begin{itemize}
% \item |vt-1|: generate PDF/VT-1. Experimental, not fully implemented.
% \item |vt-2|: generate PDF/VT-2. Experimental, not fully implemented.
% \item |vt-2s|: generate PDF/VT-2s. Experimental, not fully implemented.
% \end{itemize}
% By `Experimental, not fully implemented' here we mean primarily that 
% the structuring of a document into `/DPart' sections, as Form XObjects,
% is not handled by this package. 
% This \emph{is} possible with current \pdftex\ software, 
% but not yet in a way that lends itself easily to full automation, due to
% requirements of knowing the internal object number of certain internal
% PDF constructs. All the other aspects: PDFInfo declaration, Metadata 
% and Color Profile, of the PDF/VT variants are correctly handled. 
%
% \subsubsection{PDF/X options}
%
% PDF/X is an ISO standard intended for graphics interchange. It
% emphasizes printing-related requirements, such as embedded fonts and
% color profiles. The PDF/X standard has a large number of variants
% and conformance levels. The basic variants are known as X-1, X-1a,
% X-3, X-4, and X-5. (Note that a revised version of the X-2 standard 
% was published in 2003, but withdrawn as an ISO standard in 2011, 
% basically due to lack of interest in using it). 
% The PDF/X-1a standard exists in revisions of 2001 and 2003, 
% the PDF/X-3 standard exists in revisions of 2002 and 2003, 
% and the PDF/X-4 and PDF/X-5 standards exist in revisions of 2008 and 2010. 
% Moreover, some of these standards have a `p' version, which permits the 
% use of an externally supplied color profile (instead of an embedded one),
% and/or a `g' version, which permits the use of external graphical
% content. Moreover, PDF/X-5 has an `n' version, which extends
% PDF/X-4p by permitting additional color spaces other than Grayscale,
% RGB, and CMYK. For many typical uses of PDF/X, it is sufficient to
% use PDF/X-1a.
%
% \begin{itemize}
% \item |x-1|:    generate PDF/X-1.
% \item |x-1a|:   generate PDF/X-1a. Options |x-1a1| and |x-1a3| are
% also available to specify PDF/X-1a:2001 or PDF/X-1a:2003 explicitly.
% \item |x-3|:    generate PDF/X-3. Options |x-302| and |x-303| are
% also available to specify PDF/X-3:2002 or PDF/X-3:2003 explicitly.
% \item |x-4|:    generate PDF/X-4. Options |x-408| and |x-410| are            
% also available to specify PDF/X-4:2008 or PDF/X-4:2010 explicitly.
% \item |x-4p|:   generate PDF/X-4p. Options |x-4p08| and |x-4p10| are
% also available to specify PDF/X-4p:2008 or PDF/X-4p:2010 explicitly.
% \item |x-5g|:   generate PDF/X-5g. Options |x-5g08| and |x-5g10| are
% also available to specify PDF/X-5g:2008 or PDF/X-5g:2010 explicitly.
% \item |x-5n|:   generate PDF/X-5n. Options |x-5n08| and |x-5n10| are
% also available to specify PDF/X-5n:2008 or PDF/X-5n:2010 explicitly. 
% Experimental, not fully implemented.
% \item |x-5pg|:  generate PDF/X-5pg. Options |x-5pg08| and |x-5pg10| are
% also available to specify PDF/X-5pg:2008 or PDF/X-5pg:2010 explicitly.
% \end{itemize}
%
% \subsubsection{Other options}
%
% These options are experimental and should not normally be used.
%
% \begin{itemize}
% \item |useBOM|: generate an explicit UTF-8 byte-order marker in the
%   embedded XMP metadata, and make the XMP packet writable. Neither
%   of these features are required by the PDF/A standard, but there
%   exist some PDF/A validators (reportedly |validatepdfa.com|) that
%   seem to require them. Note: the implementation of this feature is
%   experimental and may break with future updates to the |xmpincl|
%   package.
% \item |noBOM|: do not generate the optional byte-order marker. (default)
% \item |pdf13|: use PDF 1.3, overriding the version specified by the
% applicable standard. This may produce a non-standard-conforming PDF file.
% \item |pdf14|: use PDF 1.4, overriding the version specified by the
% applicable standard. This may produce a non-standard-conforming PDF file.
% \item |pdf15|: use PDF 1.5, overriding the version specified by the
% applicable standard. This may produce a non-standard-conforming PDF file.
% \item |pdf16|: use PDF 1.6, overriding the version specified by the
% applicable standard. This may produce a non-standard-conforming PDF file.
% \item |pdf17|: use PDF 1.7, overriding the version specified by the
% applicable standard. This may produce a non-standard-conforming PDF file.
% \end{itemize} 
%
% \subsection{Data file for metadata}\label{ssec-metadata}
%
% As mentioned above, standards-compliant PDF documents require metadata
% to be included. The |pdfx| package expects the metadata to be
% supplied in a special data file called |\jobname.xmpdata|. Here,
% |\jobname| is usually the basename of the document's main |.tex|
% file. For example, if your document source is in the file
% |main.tex|, then the metadata must be in a file called
% |main.xmpdata|. None of the individual metadata fields are
% mandatory, but for most documents, it makes sense to define at least
% the title and the author. Here is an example of a short |.xmpdata|
% file:
% \begin{verbatim}
%   \Title{Baking through the ages}
%   \Author{A. Baker\sep C. Kneader}
%   \Keywords{cookies\sep muffins\sep cakes}
%   \Publisher{Baking International}
% \end{verbatim}
% You should note that multiple authors and keywords have been separated
% by |\sep|. The |\sep| macro is only permitted in within the
% |\Author|, |\Keywords|, and |\Publisher| fields.
%
% After processing, the local directory contains a file named such as
% |pdfa.xmpi| or |pdfx.xmpi| according to the PDF variant required.
% This file is the complete XMP Metadata packet. It can be checked for
% validity, using an online validator, such as at 
% \href{http://www.pdflib.com/knowledge-base/xmp-metadata/free-xmp-validator/}{www.pdflib.com}.
% 
% \textbf{Warning}: The |\jobname.xmpdata| file may be included in the
% main document source, within a |{filecontents}| environment, 
% but \emph{only} when it contains \emph{no} non-ascii UTF-8 byte sequences.
% See Section~\ref{ssec-symbols} below for more information.
% 
% \subsection{List of supported metadata fields}
% 
% Here is a complete list of user-definable metadata fields currently
% supported, and their meanings. More may be added in the future.
% These commands can only be used in the |.xmpdata| file.
% 
% \subsubsection{General information:}
% 
% \begin{itemize}
% \item |\Author|: the document's human author. Separate multiple
%   authors with |\sep|.
% \item |\Title|: the document's title.
% \item |\Keywords|: list of keywords, separated with |\sep|.
% \item |\Subject|: the abstract.
% \item |\Publisher|: the publisher.
% \end{itemize}
%
% \subsubsection{Copyright information:}
%
% \begin{itemize}
% \item |\Copyright|: a copyright statement.
% \item |\CopyrightURL|: location of a web page describing the owner
%   and/or rights statement for this document.
% \item |\Copyrighted|: `True' if the document is copyrighted, 
%  and `False' if it isn't. This is automatically set to `True' 
%  if either |\Copyright| or |\CopyrightURL| is specified, but can 
%  be overridden. For example, if the copyright statement is 
%  `Public Domain', this should be set to `False'.
% \end{itemize}
% 
% \subsubsection{Publication information:}
%
% \begin{itemize}
% \item |\PublicationType|: The type of publication. If defined, must
%   be one of `book', `catalog', `feed', `journal', `magazine', `manual',
%   `newsletter', `pamphlet'. This is automatically set to `journal'
%   if |\Journaltitle| is specified, but can be overridden.
% \item |\Journaltitle|: The title of the journal in which the
%   document was published.
% \item |\Journalnumber|: The ISSN for the publication in which the
%   document was published.
% \item |\Volume|: Journal volume.
% \item |\Issue|: Journal issue/number.
% \item |\Firstpage|: First page number of the published version of
%   the document.
% \item |\Lastpage|: Last page number of the published version of the
%   document.
% \item |\Doi| : Digital Object Identifier (DOI) for the document,
%   without the leading `doi:'.
% \item |\CoverDisplayDate|: Date on the cover of the journal issue,
%   as a human-readable text string.
% \item |\CoverDate|: Date on the cover of the journal issue, in a
%   format suitable for storing in a database field with a `date'
%   data type; e.g. YYYY-MM, or YYYY-MM-DD.
% \end{itemize}
%
% \subsubsection{Backward Compatibility}
% The following macros are also recognised, for backward compatibility 
% with earlier versions of the package.
%  \begin{itemize}
%  \item |\Creator|: synonymous with |\CreatorTool| which is usually handled
%   automatically anyway, but can be over-ridden.
%  \item |\Org|: synonymous with |\Publisher|.
%  \item |\WebStatement|: synonymous with |\CopyrightURL|.
%  \end{itemize}
% 
% \subsection{Symbols permitted in metadata}\label{ssec-symbols}
%
% Within the metadata, all printable ASCII characters except
% |\|, |{|, |}| and |%| 
% represent themselves. Also, all printable
% Unicode characters from the basic multilingual plane (i.e., up to
% code point U+FFFF) can be used directly with the UTF-8 encoding.
% (Please note: encodings other than UTF-8 are not currently supported
% in the metadata). Consecutive whitespace characters are combined
% into a single space. Whitespace after a macro such as |\copyright|,
% |\backslash|, or |\sep| is ignored. Blank lines are not permitted.
% Moreover, the following markup can be used:
%
% \begin{itemize}
% \item ``|\ |'':           a literal space  (for example after a macro)
% \item |\%|:           a literal |%|
% \item |\{|:           a literal |{|
% \item |\}|:           a literal |}|
% \item |\backslash|:   a literal backslash |\|
% \item |\copyright|:   the copyright symbol \textcopyright
% \end{itemize}
% The macro |\sep| is only permitted within |\Author|, |\Keywords|,
% and |\Publisher|. It's intention is to separate multiple authors,
% keywords, etc. However for validation purposes, multiple authors
% and keywords must not really be separated. The package takes care
% of this, even when |\sep| is used.
%
% \medskip
% Other \TeX\ macros actually can be used, provided the author is very 
% careful and not ask for too-complicated \TeX\ or \LaTeX\ expansions
% into internal commands or non-character primitives; basically just accents,
% macros for Latin-based special characters, and simple textual replacements,
% perhaps with a simple parameter. A special macro |\pdfxEnableCommands{...}| 
% is provided to help resolve difficulties that may arise.
%
% Here is an example of the use of |\pdfxEnableCommands|, which occurs 
% with the name of one of our authors {(H\`an Th\'{\^e} Thanh)} 
% due to the doubly-accented letter \'{\^e}.
% It is usual to define a macro such as: |\def\thanh{H\`an Th\'{\^e} Thanh}|.
%
% In previous versions of the |pdfx| package, use of such a macro 
% within the |.xmpdata| file, in the |Copyright| information say,
% could result in the accent macros expanding into internal primitives, such as 
% \begin{verbatim}
%  H\unhbox \voidb@x \bgroup \let \unhbox \voidb@x \setbox \@tempboxa ...
% \end{verbatim}
% \removelastskip\noindent
% going on for many lines. This clearly has no place within the XMP Metadata.
% To get around this, one could try using simplified macro definitions
% \begin{verbatim}
%   \pdfxEnableCommands{
%       \def\`#1{#1^^cc^80}\def\'#1{#1^^cc^81}\def\^#1{#1^^cc^82}}
% \end{verbatim}
% \removelastskip\noindent
% where the |^^cc^80|, |^^cc^81|, |^^cc^82| cause \TeX\ to generate the correct 
% UTF-8 bytes for `combining accent' characters.
%
% This works fine for metadata fields that appear just in the XMP packet.
% However, it is not sufficient for the PDF |/Author| key, which must exactly match
% with the |dc:creator| Metadata element. What is needed instead is
% \begin{verbatim}
%   \pdfxEnableCommands{
%        \def\thanh{H^^c3^^a0n Th\eee Thanh}\def\eee{^^c3^^aa^^cc^^81 }}
% \end{verbatim}
% \removelastskip\noindent
% or the above with `\`a' typed directly as UTF-8 instead of |^^c3^^a0| 
% and `\^e' in UTF-8 for |^^c3^^aa|.
% The reason for this is due to the |\pdfstringdef| command, which constructs
% the accented latin letters as single combined characters \`a and \^e, 
% without resorting to combining accents, wherever possible.
% If the Metadata does not have the same, irrespective of Unicode normalisation, 
% then validation fails.
%
% With this latest version (1.5.6) of the |pdfx| package, such difficulties
% have been overcome, at least for characters used in Western European, 
% Latin-based languages. The input encoding used when reading the |.xmpdata| 
% file now includes interpretations of \TeX's usual accent commands to 
% produce the required UTF-8 byte sequences.
% Work is ongoing to extend this input encoding to include macro definitions 
% for more special characters (e.g., extended Latin, Cyrillic, Greek, etc.). 
% A significant portion of the Unicode Basic Plane characters can be covered
% this way. Modules could even be provided for CJK character sets and 
% mathematical symbols, etc. However, this can become memory intensive,
% so significant testing will be required before this becomes a standard
% part of the |pdfx| package. 
% 
% \textbf{Warning}: This encoding of macros, using ascii characters only,
% allows for the convenience of including the |\jobname.xmpdata| file 
% in the main \LaTeX\ source preamble, within a |{filecontents}| environment.
% This \emph{only} works when it contains \emph{no} non-ascii UTF-8 byte 
% sequences. The |{filecontents}| environment is best placed immediately
% \emph{before} the |\usepackage[...]{pdfx}| command.
%
% 
% \subsection{Color profiles}
%
% Most standards compliant PDF documents require a \emph{color
% profile} to be embedded within the file. In a nutshell, such a profile
% determines precisely how the colors used in the document will be
% rendered when printed to a physical medium. This can be used to
% ensure that the document will look exactly the same, even when it is
% printed on different printers, with different paper types, etc. 
% The inclusion of a color profile is necessary to make the document 
% completely self-contained.
%
% Since most \LaTeX\ users are not graphics professionals and are not
% particularly picky about colors, the |pdfx| package includes default
% profiles that will be included when nothing else is specified. 
% Therefore, the average user doesn't have to do anything
% special about color.
%
% For users who have a specific color profile they wish to use, it is
% possible to do so by including a |\setRGBcolorprofile| or
% |\setCMYKcolorprofile| command in the |.xmpdata| file. Note that
% PDF/A and PDF/E require an RGB color profile, and PDF/X and PDF/VT
% require a CMYK color profile. Use the following commands to specify
% an RGB or CMYK color profile, respectively:
% 
% \begin{decl}
% \defmacro{setRGBcolorprofile}\marg{filename}\marg{identifier}\marg{info
% string}\marg{registry URL}
% \\[1ex]
% \defmacro{setCMYKcolorprofile}\marg{filename}\marg{output
% intent}\marg{identifier}\marg{registry URL}
% \end{decl}
% Within the arguments of these macros, the characters |<|, |>|, |&|,
% |^|, |_|, |#|, |$|, and |~| can be used as themselves, but
% |%| must be escaped as |\%|. The defaults are:
% \begin{verbatim}
% \setRGBcolorprofile{sRGB_IEC61966-2-1_black_scaled.icc}
%                    {sRGB_IEC61966-2-1_black_scaled}
%                    {sRGB IEC61966 v2.1 with black scaling}
%                    {http://www.color.org}
%
% \setCMYKcolorprofile{coated_FOGRA39L_argl.icc}
%                     {Coated FOGRA39}
%                     {FOGRA39 (ISO Coated v2 300\% (ECI))}
%                     {http://www.argyllcms.com/}
% \end{verbatim}
%
% Some color profile files may be obtained from the International
% Color Consortium.  Please take a look at
% \url{http://www.color.org/iccprofile.xalter}.
%
% Alternatively, color profiles are shipped with many Adobe software
% applications; these are then available for use also with non-Adobe 
% software. Now the |pdfx| package includes coding to streamline
% inclusion of these profiles in PDF documents, or to specify
% them as `external' profiles, with PDF/X-4p and PDF/X-5pg variants.
% Two files |AdobeColorProfiles.tex| and |AdobeExternalProfiles.tex|
% are distributed with the |pdfx| package. The latter is for use
% with PDF/X-4p and PDF/X-5pg, which do not require color profiles to
% be embedded, while the former can be used with other PDF/X variants.
% Both define commands to use Color Profiles as follows.
% \begin{center}
% \begin{tabular}{ll}
%  \texttt{\string\FOGRAXXXIX} & Coated FOGRA39 (ISO 12647-2:2004)\\    
%  \texttt{\string\SWOPCGATSI} & U.S. Web Coated (SWOP) v2\\
%  \texttt{\string\JapanColorMMICoated} & Japan Color 2001 Coated\\  
%  \texttt{\string\JapanColorMMIUncoated} & Japan Color 2001 Uncoated\\  
%  \texttt{\string\JapanColorMMIINewspaper} & Japan Color 2002 Newspaper\\  
%  \texttt{\string\JapanWebCoatedAd} & Japan Web Coated (Ad)\\ 
%  \texttt{\string\CoatedGRACoL} & Coated GRACoL 2006 (ISO 12647-2:2004)\\    
%  \texttt{\string\SNAPCGATSII} & CGATS TR 002\\
%  \texttt{\string\SWOPCGATSIII} & CGATS TR 003\\
%  \texttt{\string\SWOPCGATSV} & CGATS TR 005\\
%  \texttt{\string\ISOWebCoated} & Web Coated FOGRA28 (ISO 12647-2:2004)\\ 
%  \texttt{\string\ISOCoatedECI} & ISO Coated v2 (ECI)\\
%  \texttt{\string\CoatedFOGRA} & Coated FOGRA27 (ISO 12647-2:2004)\\
%  \texttt{\string\WebCoatedFOGRA} & Web Coated FOGRA28 (ISO 12647-2:2004)\\
%  \texttt{\string\UncoatedFOGRA} & Uncoated FOGRA29 (ISO 12647-2:2004)\\
%  \texttt{\string\IFRAXXVI} & ISOnewspaper26v4 ISO/DIS 12647-3:2004\\
%  \texttt{\string\IFRAXXX} & ISOnewspaper30v4 ISO/DIS 12647-3:2004\\
% \end{tabular}
% \end{center}
% As of the time of writing, only the first six of these result in PDFs
% which can validate with external profiles (i.e., for PDF/X-4p and PDF/X-5pg)
% using current versions of Adobe Acrobat Pro software. It is unclear
% whether the others (incl.\,\verb|\IFRAXXVI| and \verb|\IFRAXXX|) fail due 
% to incorrect data or problems in the validation software. 
% All but those last two can be used for valid embedded profiles,
% providing the corresponding files can be found. The following macro
% is used to set the (absolute or relative) path, on the local operating system,
% to the location of color profile files.
% \begin{decl}
%  \defmacro{pdfxSetRGBcolorProfileDir}\marg{path to RGB color profiles}\\
%  \defmacro{pdfxSetCMYKcolorProfileDir}\marg{path to CMYK profiles}
% \end{decl}
% On a Macintosh, one can use \texttt{\string\AdobeMacOSdir} which expands to 
% the path \texttt{/Library/Application Support/\allowbreak 
%  Adobe/\allowbreak Color\allowbreak /Profiles/\allowbreak Recommended/}.
% Under Windows the corresponding macro is \texttt{\string\WindowsColordir}
% which expands: 
% \texttt{C:\string\Windows\allowbreak\string\System32\allowbreak
%  \string\Spool\allowbreak\string\Drivers\allowbreak\string\Color\string/}.
% Use these within the \verb|.xmpdata| file as, e.g., 
%  |\pdfxSetCMYKcolorProfileDir{\AdobeMacOSdir}|.
% Authors should change the paths to suit their own circumstances, either
% \emph{before} loading |pdfx.sty| or within the \verb|.xmpdata| file. 
%
% PDF/A and PDF/E usually need an RGB profile, while PDF/X and PDF/VT
% require a CMYK profile. It is possible to use a CMYK profile with PDF/A 
% or PDF/E by specifying |\setRGBcolorprofile{}{}{}{}| in the \verb|.xmpdata| file.
% Beware however, that with PDF/A any coloured hyperlink annotations can
% cause a validation problem, as these are interpreted as RGB colours 
% even when 4 components are given. This may be a bug in validators,
% as PDF specifies that the number of components should match the color space.
% 
%
% \subsection{Notes on the internal representation of metadata}
%                    
% Within the PDF file, metadata is deposited in two places: some data
% goes into the native PDF |/Info| dictionary, and some data goes into
% an XMP packet stored separately within the file. XMP is Adobe's
% Extensible Metadata Platform, and is an XML-based format. See
% \href{http://www.adobe.com/devnet/xmp/}{Adobe XMP Development
% Center} for more exhaustive information about XMP.  An XMP Toolkit
% SDK which supports the GNU/Linux, Macintosh and Windows operating
% systems is also provided under modified BSD licence.
%
% Some of the metadata, such as the author, title, and keywords, are
% stored \emph{both} in the XMP packet and in the |/Info|
% dictionary. For the resulting file to be standards-compliant, the two
% copies of the data must be identical. All of this is taken care of
% automatically by the |pdfx| package.
% 
% In principle, users can resort to alternate ways to create an XMP
% file for inclusion in PDF. In this case, users should create a file
% |pdfa.xmp| or |pdfx.xmp| (etc., depending on the PDF flavor)
% containing the pre-defined data. However, this is an error-prone
% process and is not recommended for most users. If there is a
% particular field of metadata that you need and that is not currently
% supported, please contact the package authors.
%
% |pdfx| makes use of the |xmpincl| package to include |xmp| data into
% the PDF.  The documentation of |xmpincl| package may help interested
% users to understand the process of |xmp| data inclusion.
% 
% \subsection{Tutorials and technical notes}
%
% A tutorial with step-by-step instructions for generating PDF/A files
% can be found at:
% \url{http://www.mathstat.dal.ca/~selinger/pdfa/}.
%
% Some technical notes about production problems the authors have
% encountered while generating PDF/A compliant documents are available
% here:
% \url{http://support.river-valley.com/wiki/index.php?title=Generating_PDF/A_compliant_PDFs_from_pdftex}.
%
% 
%
% \section[Installing]{Installing}
% The |pdfx.dtx| package is available on CTAN as usual, via
%  \url{http://ctan.org/pkg/pdfx}. It is also included in
% \TeX\ distributions such as Mac\TeX, \TeX\ Live and MiK\TeX.
% Thus most users will not need to handle installation at all.
%
% For those wishing to do a manual installation, here are some notes.
% The file |pdfx.dtx| is a composite document of program code and
% documentation in \LaTeX{} format, in the tradition of \emph{literate
% programming}. After having installed the package, 
% to get the documentation that you are reading now,
% run (\textsc{pdf})\LaTeX{} on the file |pdfx.dtx|. 
% The resulting PDF should be valid as PDF/A-2u.
% % Or better, use
% % the included |Makefile|, which will also regenerate the index.
%
% To install the package, first extract the program code; i.e., the
% file |pdfx.sty|, by running \LaTeX{} or \TeX{} on the file
% |pdfx.ins|. Create a directory named |pdfx| under |$TEXMF/tex/latex|
% and copy the files |pdfx.sty|, |8bit.def|, |glyphtounicode-cmr.tex|,
% as well as the |*.icc| and |*.xmp| files, into it. Then update \TeX's
% file database using the appropriate command for your distribution and
% operating system (such as |texhash| or |mktexlsr|, or similar).
% 
% \subsection{Limitations and dependencies}
% 
%  |pdfx.sty| works with \pdftex\ and also Lua\TeX.  
%  It further depends on the following other packages:
%  \begin{enumerate}
%  \item |xmpincl|  for insertion of metadata into PDF.
%  \item |hyperref| for hyperlinking, bookmarks, etc.
%  \item |glyphtounicode.tex| maps glyph names to corresponding Unicode.
%  \end{enumerate}
%
% \subsection{Files included}
%
% The following files are included in the package.
% Some can be created from |pdfx.dtx|, using the |Makefile|.
%
% \subsubsection{Package files}
%
% \begin{itemize}
% \item |pdfx.sty| --- main package file generated from |pdfx.dtx|.
% \item |pdfa.xmp| --- specimen |xmp| template for PDF/A.
% \item |pdfe.xmp| --- specimen |xmp| template for PDF/E.
% \item |pdfvt.xmp| --- specimen |xmp| template for PDF/VT.
% \item |pdfx.xmp| --- specimen |xmp| template for PDF/X.
% \item |8bit.def| --- custom input encoding.
% \item |l8uenc.def| --- input encoding macro declarations.
% \item |glyphtounicode-cmr.tex| --- maps glyph names to corresponding
%   Unicode for Computer Modern and other \TeX-specific fonts.
% \item |coated_FOGRA39L_argl.icc| --- CMYK color profile 
%   (freely distributable).
% \item |sRGB_IEC61966-2-1_black_scaled.icc| --- RGB color profile
%  freely distributable.
% \item |ICC_LICENSE.txt| --- license for the color profiles.
% \item |AdobeColorProfiles.tex| --- macros for inclusion of Adobe-supplied color profiles.
% \item |AdobeExternalProfiles.tex| --- macros for use of external color profiles.
% \end{itemize}
% 
% \subsubsection{Documentation}
% 
% \begin{itemize}
% \item |README| --- usual top-level information.
% \item |manifest.txt| --- file list.
% \item |sample.tex|, |sample.xmpdata| --- a sample file with sample
%   metadata.
% \item |small2e-pdfx.tex|, |small2e-pdfx.xmpdata| --- another sample
%   file with sample metadata.
% \end{itemize}
% 
% \subsubsection{Sources}
% 
% \begin{itemize}
% \item |src/pdfx.dtx| --- composite package and documentation.
% \item |src/pdfx.ins| --- installer batch file.
% \item |src/pdfx.xmpdata| --- metadata for the documentation.
% \item |src/rvdtx.sty| --- used by |pdfx.dtx|.
% \item |src/Makefile| --- a Makefile for building the documentation.
% \end{itemize}
%
% \subsection{Miscellaneous information}
%
% The package is released under the \LaTeX{} Project Public
% Licence. Bug reports, suggestions, feature requests, etc., may be
% sent to the original authors at 
% \href{mailto:cvr@river-valley.org}{\ttfamily cvr@river-valley.org}
% and/or 
% \href{mailto:thanh@river-valley.org}{\ttfamily thanh@river-valley.org},
% or to the more recent contributors at
% \href{mailto:ross.moore@mq.edu.au}{\ttfamily ross.moore@mq.edu.au}
% and/or
% \href{mailto:selinger@mathstat.dal.ca}{\ttfamily selinger@mathstat.dal.ca}.
% 
% \section[Bibliography]{Bibliography}
% \begin{thebibliography}{999}
%
% \bibitem{PDF17}Adobe Systems Inc.;
% {PDF} Reference 1.7, November 2006.
% Also available as \cite{ISO32000}.\\
% \url{http://www.adobe.com/devnet/pdf/pdf_reference.html}.
%
% \bibitem{DC}
% Dublin Core Metadata Element Set, Version 1.1, October 2010 
% \url{http://dublincore.org/documents/dces/}
%
% \bibitem{PDFA}ISO\,19005-1:2005;
% Document Management --- Electronic document file format for long term preservation
% --- Part 1: Use of PDF\,1.4\,(PDF/A-1);
% Technical Committee ISO/TC\,171/SC\,2  (Sept. 2005).
% Revisions via Corrigenda: ISO\,19005-1:2005/Cor\,1:2007 (March 2007); 
% ISO\,19005-1:2005/Cor\,2:2011 (Dec. 2011). \\
% \url{http://www.iso.org/iso/catalogue_detail?csnumber=38920}.
%
% \bibitem{PDFA2}ISO\,19005-2:2011;
% Document Management --- Electronic document file format for long term preservation
% --- Part 2: Use of ISO\,32000-1\,(PDF/A-2);
% Technical Committee ISO/TC\,171/SC\,2 (June 2011).
% \url{http://www.iso.org/iso/catalogue_detail?csnumber=50655}. 
%
% \bibitem{PDFA3}ISO\,19005-3:2012;
% Document Management --- Electronic document file format for long term preservation
% --- Part 3: Use of ISO\,32000-1 with support for embedded files (PDF/A-3);
% Technical Committee ISO/TC\,171/SC\,2 (October 2012).\\
% \url{http://www.iso.org/iso/catalogue_detail?csnumber=57229}. 
%
% \bibitem{ISO32000}ISO\,32000-1:2008;
% Document management\,---\,Portable document format\,(PDF\,1.7);
% Technical Committee ISO/TC\,171/SC\,2 (July 2008). 
% Also available as \cite{PDF17}.\\
% \url{http://www.iso.org/iso/catalogue_detail?csnumber=51502}.
%
% \bibitem{PDF20}ISO\,32000-2-20140220;
% Document management --- Portable document format --- Part~2: PDF\,2.0;
% Technical Committee ISO/TC\,171/SC\,2, in draft form (Feb. 2014).
%
% \bibitem{PDFE}ISO\,24517-1:2008;
% Document Management --- Engineering document format using PDF --- Part 1: 
% Use of PDF 1.6 (PDF/E-1);
% Technical Committee ISO/TC\,171/SC\,2 (May 2008).\\
% \url{http://www.iso.org/iso/catalogue_detail?csnumber=42274}. 
%
% \bibitem{PDFUA1}ISO\,14289-1:2012;
% Document management applications --- Electronic document file format enhancement for accessibility
% --- Part 1: Use of ISO\,32000-1\,(PDF/UA-1);
% Technical Committee ISO/TC\,171/SC\,2 (July 2012).
% \url{http://www.iso.org/iso/home/store/catalogue_tc/catalogue_detail.htm?csnumber=54564}.\\
% Revised as ISO\,14289-1:2014 (December 2014): 
% \url{http://www.iso.org/iso/home/store/catalogue_tc/catalogue_detail.htm?csnumber=64599}.
%
% \bibitem{PDF-UA}
% PDF/UA Technical Implementation Guide: Understanding ISO\,14289-1 (PDF/UA-1). \penalty-200
% AIIM Global Community of Information Professionals. 
% \href{http://www.aiim.org/Research-and-Publications/standards/committees/PDFUA/Technical-Implementation-Guide}%
% {{\tt http://www.aiim.org/Re\penalty-200 search-and-Publications/standards/committees/PDFUA/Technical-Implementation\penalty-200 -Guide}}.
%
%
% \bibitem{PDFVT}ISO\,16612-2:2010;
% Graphic technology\,---\,Variable data exchange\,---\,Part 2: 
% Using PDF/X-4 \penalty-5000 and PDF/X-5 (PDF/VT-1 and PDF/VT-2).
% Technical Committee ISO/TC\,130 (December 2005).
% \href{http://www.iso.org/iso/home/store/catalogue_tc/catalogue_detail.htm?csnumber=38013}{{\tt http://www.iso.org/iso/home/store/catalogue\_tc/catalogue\_detail.htm?\penalty-200csnumber=38013}}.
%
%
% \bibitem{PDFX}ISO\,15930-1:2001;
% Graphic technology --- Prepress digital data exchange --- Use of PDF --- Part 1: 
% Complete exchange using CMYK data (PDF/X-1 and PDF/X-1a).
% Technical Committee ISO/TC\,130 (December 2001).
% \url{http://www.iso.org/iso/home/store/catalogue_tc/catalogue_detail.htm?csnumber=29061}.
%
% \bibitem{PDFX3}ISO\,15930-3:2002;
% Graphic technology --- Prepress digital data exchange --- Use of PDF --- Part 3: 
% Complete exchange suitable for colour-managed workflows (PDF/X-3).
% Technical Committee ISO/TC\,130 (September 2002).
% \url{http://www.iso.org/iso/home/store/catalogue_tc/catalogue_detail.htm?csnumber=34941}.
%
% \bibitem{PDFX1a}ISO\,15930-4:2003;
% Graphic technology --- Prepress digital data exchange --- Use of PDF --- Part 4: 
% Complete exchange of CMYK and spot colour printing data using PDF 1.4 (PDF/X-1a).
% Technical Committee ISO/TC\,130 (December 2003).
% \url{http://www.iso.org/iso/home/store/catalogue_tc/catalogue_detail.htm?csnumber=39938}.
%
% \bibitem{PDFX3a}ISO\,15930-6:2003;
% Graphic technology --- Prepress digital data exchange --- Use of PDF --- Part 6: 
% Complete exchange of printing data suitable for colour-managed workflows using PDF 1.4 (PDF/X-3).
% Technical Committee ISO/TC\,130 (December 2003).
% \url{http://www.iso.org/iso/home/store/catalogue_tc/catalogue_detail.htm?csnumber=39940}.
%
% \bibitem{PDFX4}ISO\,15930-7:2010;
% Graphic technology --- Prepress digital data exchange --- Use of PDF --- Part 7: 
% Complete exchange of printing data (PDF/X-4) and partial exchange of printing data with external profile reference (PDF/X-4p) using PDF 1.6.
% Technical Committee ISO/TC\,130 (July 2010).
% \url{http://www.iso.org/iso/home/store/catalogue_tc/catalogue_detail.htm?csnumber=55843}.
%
% \bibitem{PDFX5}ISO\,15930-8:2010;
% Graphic technology --- Prepress digital data exchange --- Use of PDF --- Part 8: 
% Partial exchange of printing data using PDF 1.6 (PDF/X-5).
% Technical Committee ISO/TC\,130 (July 2010).
% \url{http://www.iso.org/iso/home/store/catalogue_tc/catalogue_detail.htm?csnumber=55844}.
% Revision via Corrigendum: ISO\,15930-8:2010/Cor\,1:2011 (August 2011);
% \url{http://www.iso.org/iso/home/store/catalogue_tc/catalogue_detail.htm?csnumber=60210}.
%
% \bibitem{XMP}ISO\,16684-1:2012;
% Graphic technology --- Extensible metadata platform (XMP) specification --- Part 1: 
% Data model, serialization and core properties.
% Technical Committee ISO/TC\,130 (February 2012).
% \url{http://www.iso.org/iso/home/store/catalogue_tc/catalogue_detail.htm?csnumber=57421}.
%
% \bibitem{pdfx}C.\,V.\,Radhakrishnan, \Thanh, Ross Moore, Peter Selinger;
% Generation of PDF/X- and PDF/A-compliant PDFs with pdf\TeX{} --- \texttt{pdfx.sty}.
% TUGboat Vol.\,36, No.\,2; TUG 2015 Conference Proceedings. \TeX\ Users Group, 2015; pp.\,136--142.
% \end{thebibliography}
% \end{document}
% \section[Implementation]{Implementation}
% 
% \iffalse
%<*package>
% \fi
%    \begin{macrocode}
\@ifpackageloaded{pdfxmult}{%
 \PackageError{pdfx}%
  {^^JThis package may not be used in conjunction with the \space pdfxmult \space package}%
  {Type \space x <return> \space to exit; or just \space <return> \space to continue without this package.}%
 \expandafter\let\csname opt@pdfx.sty\endcsname\@empty\endinput
}{}%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{pdfx}
  [2016/02/04 v1.5.6 PDF/X and PDF/A support (CVR/HTH/RRM/PS)]

\newif\ifpdfx@noBOM \pdfx@noBOMfalse   % use a BOM in the XMP packet
\newif\ifpdfx@x \pdfx@xfalse   % PDF/X mode
\newif\ifpdfx@e \pdfx@efalse   % PDF/E mode; not implemented yet
\newif\ifpdfx@vt \pdfx@vtfalse   % PDF/VT mode, extension of  PDF/X
\newif\ifno@iccprofile   % used with PDF/X-4p and PDF/X-5pg

%% Not all combinations of the following parameters are meaningful.
\def\xmp@Part{1}               % PDF/A part: 1, 2, or 3
\def\xmp@Conformance{B}        % Conformance level: A, B, or U
\def\xmp@ReleaseDate{2005}     % 2001 for PDF/X-1, 2005 for PDF/A-1,
                               % 2010 for PDF/A-2, 2012 for PDF/A-3.

%%  default is to create  PDF/A-1b   
%%  options can change this for PDF/X or higher levels of PDF/A 
\DeclareOption{a-1a}{\global\pdfx@xfalse\def\xmp@Part{1}\def\xmp@Conformance{A}\def\xmp@ReleaseDate{2005}}
\DeclareOption{a-1b}{\global\pdfx@xfalse\def\xmp@Part{1}\def\xmp@Conformance{B}\def\xmp@ReleaseDate{2005}}
\DeclareOption{a-2a}{\global\pdfx@xfalse\def\xmp@Part{2}\def\xmp@Conformance{A}\def\xmp@ReleaseDate{2010}}
\DeclareOption{a-2b}{\global\pdfx@xfalse\def\xmp@Part{2}\def\xmp@Conformance{B}\def\xmp@ReleaseDate{2010}}
\DeclareOption{a-2u}{\global\pdfx@xfalse\def\xmp@Part{2}\def\xmp@Conformance{U}\def\xmp@ReleaseDate{2010}}
\DeclareOption{a-3a}{\global\pdfx@xfalse\def\xmp@Part{3}\def\xmp@Conformance{A}\def\xmp@ReleaseDate{2012}}
\DeclareOption{a-3b}{\global\pdfx@xfalse\def\xmp@Part{3}\def\xmp@Conformance{B}\def\xmp@ReleaseDate{2012}}
\DeclareOption{a-3u}{\global\pdfx@xfalse\def\xmp@Part{3}\def\xmp@Conformance{U}\def\xmp@ReleaseDate{2012}}
\DeclareOption{x-1}{\global\pdfx@xtrue\def\xmp@Part{1}\def\xmp@Conformance{a}\def\xmp@ReleaseDate{2001}\global\pdfminorversion=3 }
\DeclareOption{x-1a}{\global\pdfx@xtrue\def\xmp@Part{1}\def\xmp@Conformance{a}\def\xmp@ReleaseDate{2003}\global\pdfminorversion=3 }
\DeclareOption{x-1a1}{\global\pdfx@xtrue\def\xmp@Part{1}\def\xmp@Conformance{a}\def\xmp@ReleaseDate{2001}\global\pdfminorversion=3 }
\DeclareOption{x-1a3}{\global\pdfx@xtrue\def\xmp@Part{1}\def\xmp@Conformance{a}\def\xmp@ReleaseDate{2003}\global\pdfminorversion=3 }
\DeclareOption{x-2}{\global\pdfx@xtrue\def\xmp@Part{2}\def\xmp@Conformance{}\def\xmp@ReleaseDate{2002}\global\pdfminorversion=4 }
\DeclareOption{x-3}{\global\pdfx@xtrue\def\xmp@Part{3}\def\xmp@Conformance{}\def\xmp@ReleaseDate{2002}\global\pdfminorversion=3 }
\DeclareOption{x-302}{\global\pdfx@xtrue\def\xmp@Part{3}\def\xmp@Conformance{}\def\xmp@ReleaseDate{2002}\global\pdfminorversion=3 }
\DeclareOption{x-303}{\global\pdfx@xtrue\def\xmp@Part{3}\def\xmp@Conformance{}\def\xmp@ReleaseDate{2003}\global\pdfminorversion=4 }
%%%  Later versions, yet to be fully implemented
\DeclareOption{x-4}{\global\pdfx@xtrue\def\xmp@Part{4}\def\xmp@Conformance{}\def\xmp@ReleaseDate{2008}\global\pdfminorversion=6 }
\DeclareOption{x-4p}{\global\pdfx@xtrue\global\no@iccprofiletrue
  \def\xmp@Part{4}\def\xmp@Conformance{p}\def\xmp@ReleaseDate{2008}\global\pdfminorversion=6 }
\DeclareOption{x-408}{\global\pdfx@xtrue\def\xmp@Part{4}\def\xmp@Conformance{}\def\xmp@ReleaseDate{2008}\global\pdfminorversion=6 }
\DeclareOption{x-410}{\global\pdfx@xtrue\def\xmp@Part{4}\def\xmp@Conformance{}\def\xmp@ReleaseDate{2010}\global\pdfminorversion=6 }
\DeclareOption{x-4p08}{\global\pdfx@xtrue\global\no@iccprofiletrue
  \def\xmp@Part{4}\def\xmp@Conformance{p}\def\xmp@ReleaseDate{2008}\global\pdfminorversion=6 }
\DeclareOption{x-4p10}{\global\pdfx@xtrue\global\no@iccprofiletrue
  \def\xmp@Part{4}\def\xmp@Conformance{p}\def\xmp@ReleaseDate{2010}\global\pdfminorversion=6 }
\DeclareOption{x-5}{\global\pdfx@xtrue\def\xmp@Part{5}\def\xmp@Conformance{}\def\xmp@ReleaseDate{2008}\global\pdfminorversion=6 }
\DeclareOption{x-5g}{\global\pdfx@xtrue\def\xmp@Part{5}\def\xmp@Conformance{g}\def\xmp@ReleaseDate{2008}\global\pdfminorversion=6 }
\DeclareOption{x-5n}{\global\pdfx@xtrue\def\xmp@Part{5}\def\xmp@Conformance{n}\def\xmp@ReleaseDate{2008}\global\pdfminorversion=6 }
\DeclareOption{x-5pg}{\global\pdfx@xtrue\global\no@iccprofiletrue
  \def\xmp@Part{5}\def\xmp@Conformance{pg}\def\xmp@ReleaseDate{2008}\global\pdfminorversion=6 }
\DeclareOption{x-508}{\global\pdfx@xtrue\def\xmp@Part{5}\def\xmp@Conformance{}\def\xmp@ReleaseDate{2008}\global\pdfminorversion=6 }
\DeclareOption{x-5g08}{\global\pdfx@xtrue\def\xmp@Part{5}\def\xmp@Conformance{g}\def\xmp@ReleaseDate{2008}\global\pdfminorversion=6 }
\DeclareOption{x-5n08}{\global\pdfx@xtrue\def\xmp@Part{5}\def\xmp@Conformance{n}\def\xmp@ReleaseDate{2008}\global\pdfminorversion=6 }
\DeclareOption{x-5pg08}{\global\pdfx@xtrue\global\no@iccprofiletrue
  \def\xmp@Part{5}\def\xmp@Conformance{pg}\def\xmp@ReleaseDate{2008}\global\pdfminorversion=6 }
\DeclareOption{x-510}{\global\pdfx@xtrue\def\xmp@Part{5}\def\xmp@Conformance{}\def\xmp@ReleaseDate{2010}\global\pdfminorversion=6 }
\DeclareOption{x-5g10}{\global\pdfx@xtrue\def\xmp@Part{5}\def\xmp@Conformance{g}\def\xmp@ReleaseDate{2010}\global\pdfminorversion=6 }
\DeclareOption{x-5n10}{\global\pdfx@xtrue\def\xmp@Part{5}\def\xmp@Conformance{n}\def\xmp@ReleaseDate{2010}\global\pdfminorversion=6 }
\DeclareOption{x-5pg10}{\global\pdfx@xtrue\global\no@iccprofiletrue
  \def\xmp@Part{5}\def\xmp@Conformance{pg}\def\xmp@ReleaseDate{2010}\global\pdfminorversion=6 }
\DeclareOption{e-1}{\global\pdfx@xfalse\global\pdfx@etrue
  \def\xmp@Part{1}\def\xmp@Conformance{}\def\xmp@ReleaseDate{2008}\global\pdfminorversion=6 }
\DeclareOption{vt-1}{\global\pdfx@xtrue\global\pdfx@vttrue
  \def\xmp@Part{4}\def\xmp@vtPart{1}\def\xmp@Conformance{}\def\xmp@vtConformance{}%
  \def\xmp@ReleaseDate{2010}\global\pdfminorversion=6 }
\DeclareOption{vt-2}{\global\pdfx@xtrue\global\pdfx@vttrue\global\no@iccprofiletrue
  \def\xmp@Part{5}\def\xmp@vtPart{2}\def\xmp@Conformance{pg}\def\xmp@vtConformance{}%
  \def\xmp@ReleaseDate{2010}\global\pdfminorversion=6 }
\DeclareOption{vt-2s}{\global\pdfx@xtrue\global\pdfx@vttrue\global\no@iccprofiletrue
  \def\xmp@Part{5}\def\xmp@vtPart{2}\def\xmp@Conformance{pg}\def\xmp@vtConformance{s}%
  \def\xmp@ReleaseDate{2010}\global\pdfminorversion=6 }

%% extra options to alter the PDF minor version, in case needed in special circumstances
\DeclareOption{pdf13}{\global\pdfminorversion=3 }
\DeclareOption{pdf14}{\global\pdfminorversion=4 }
\DeclareOption{pdf15}{\global\pdfminorversion=5 }
\DeclareOption{pdf16}{\global\pdfminorversion=6 }
\DeclareOption{pdf17}{\global\pdfminorversion=7 }

%% inhibits writing the XMP byte-order marker
\DeclareOption{noBOM}{\pdfx@noBOMtrue}
\DeclareOption{useBOM}{\pdfx@noBOMfalse}

\pdfminorversion=4 %  assumed for PDF/A ;  options may change this for  PDF/X
\expandafter\ifx\csname pdfresetpageorigin\endcsname\relax\else
 \pdfresetpageorigin=0
\fi

\ExecuteOptions{noBOM,a-1b}
\ProcessOptions

\RequirePackage{ifluatex}
\ifluatex 
 \RequirePackage{pdftexcmds}%
 \let\pdfx@mdfivesum\pdf@mdfivesum
\else
 \let\pdfx@mdfivesum\pdfmdfivesum
\fi
 \def\pdfx@encodingfile{l8uenc.def}

{\endlinechar=-1
 \everyeof{\noexpand}%
 \xdef\pdfx@bannerstring{\expandafter\scantokens\expandafter{\pdftexbanner}}
}%
\def\pdfx@testbannerstr{%
 This is pdfTeX, Version 3.14159265-2.6-1.40.15 (TeX Live 2014/dev) kpathsea version 6.2.0dev}%
\ifx\pdfx@bannerstring\pdfx@testbannerstr
 \typeout{This version of pdfTeX cannot write out upper-range character bytes, 128-255.}%
 \typeout{Any UTF-8 Unicode characters in the Metadata will not be written correctly.}%
 \typeout{Please update to a more stable version of pdfTeX.^^J}%
\fi

\ifpdfx@x
 \pdfobjcompresslevel=0 \relax
 \expandafter\ifx\csname pdfinterwordspaceoff\endcsname\relax\else
  \pdfinterwordspaceoff
  \let\pdfinterwordspaceon\pdfinterwordspaceoff
  \let\pdfinterwordspace\relax
 \fi
 \expandafter\ifx\csname pdfgeninterwordspace\endcsname\relax\else
  \pdfgeninterwordspace=0 \relax
 \fi
 \pdfpageattr{/MediaBox[0 0 595 793]
              /BleedBox[0 0 595 793]
              /TrimBox[25 20 570 773]}
\fi
\ifnum\pdfminorversion >3 \relax
 \expandafter\ifx\csname pdfsuppresswarningdupmap\endcsname\relax
  \pdfmapline{+dummy-space <dummy-space.pfb}
 \else
  \advance\pdfsuppresswarningdupmap 1
  \pdfmapline{+dummy-space <dummy-space.pfb}
  \advance\pdfsuppresswarningdupmap -1
 \fi
 \expandafter\ifx\csname pdfgeninterwordspace\endcsname\relax\else
  \pdfgeninterwordspace=1 \relax
 \fi
\fi
%% the "pdftex" option seems to work fine with LuaTeX 
\ifpdfx@x
 \@ifpackageloaded{hyperref}{%
  \hypersetup{draft,pdftex,pdfpagemode=UseNone,bookmarks=false,pdfversion=1.\the\pdfminorversion]}
 }{%
  \RequirePackage[draft,pdftex,pdfpagemode=UseNone,bookmarks=false,pdfversion=1.\the\pdfminorversion]{hyperref}
 }%
\else
 \ifpdfx@e
  \@ifpackageloaded{hyperref}{%
   \hypersetup{draft,pdftex,pdfpagemode=UseNone,bookmarks=false,pdfversion=1.\the\pdfminorversion]}
  }{%
   \RequirePackage[draft,pdftex,pdfpagemode=UseNone,bookmarks=false,pdfversion=1.\the\pdfminorversion]{hyperref}
  }%
 \else
 \@ifpackageloaded{hyperref}{%
  \hypersetup{pdftex,pdfa}%
  \Hy@pdfatrue
 }{%
  \RequirePackage[pdftex,pdfa]{hyperref}
  \Hy@pdfatrue
 }%
\fi\fi
\hypersetup{pdfencoding=auto}%  unicode

\ifluatex\else
 \RequirePackage{inputenc}
\fi
\InputIfFileExists{\pdfx@encodingfile}{}{}

%%----------------------------------------------------------------------
%% Macros for reading XMP data with special catcodes. Usage:
%%
%% \xmp@parse{continuation}{data}
%%
%% The effect is to read the data with special catcodes: '<', '>', and
%% '&' are "active", and '^', '_', '#', '$', '~' are "other". The data
%% is then bound to the locally scoped name \@this, and the
%% continuation is called.
\def\xmp@parse#1{%
 \begingroup
 \catcode`\<=13\catcode`\>=13\catcode`\&=13\catcode`\^=12
 \catcode`\_=12\catcode`\#=12\catcode`\$=12\catcode`\~=12
 \xmp@doparse{#1}%
}
\def\xmp@doparse#1#2{%
 \def\@this{#2}#1
 \endgroup
}

%%----------------------------------------------------------------------
%% Local commands. They are only brought into scope during the reading
%% of xmpdata.
\def\pdfx@localcommands{
 \def\Title{\xmp@parse{\global\let\xmp@Title\@this}}
 \def\Author{\xmp@parse{\global\let\xmp@Author\@this}}
 \def\Keywords{\xmp@parse{\global\let\xmp@Keywords\@this}}
 \def\Subject{\xmp@parse{\global\let\xmp@Subject\@this}}
 \def\CreatorTool{\xmp@parse{\global\let\xmp@CreatorTool\@this}}
 \def\Producer{\xmp@parse{\global\let\xmp@Producer\@this}}
 \def\Volume{\xmp@parse{\global\let\xmp@Volume\@this}}
 \def\Issue{\xmp@parse{\global\let\xmp@Issue\@this}}
 \def\CoverDisplayDate{\xmp@parse{\global\let\xmp@CoverDisplayDate\@this}}
 \def\CoverDate{\xmp@parse{\global\let\xmp@CoverDate\@this}}
 \def\Copyright{\xmp@parse{\global\let\xmp@Copyright\@this%
   \ifx\xmp@Copyrighted\@empty\gdef\xmp@Copyrighted{True}\fi}}
 \def\CopyrightURL{\xmp@parse{\global\let\xmp@CopyrightURL\@this%
   \ifx\xmp@Copyrighted\@empty\gdef\xmp@Copyrighted{True}\fi}}
 \def\Copyrighted{\xmp@parse{\global\let\xmp@Copyrighted\@this}}
 \def\Doi{\xmp@parse{\global\let\xmp@Doi\@this}}
 \def\Lastpage{\xmp@parse{\global\let\xmp@Lastpage\@this}}
 \def\Firstpage{\xmp@parse{\global\let\xmp@Firstpage\@this}}
 \def\PublicationType{\xmp@parse{\global\let\xmp@PublicationType\@this}}
 \def\Journaltitle{\xmp@parse{\global\let\xmp@Journaltitle\@this%
   \ifx\xmp@PublicationType\@empty\gdef\xmp@PublicationType{journal}\fi}}
 \def\Journalnumber{\xmp@parse{\global\let\xmp@Journalnumber\@this}}
 \def\Publisher{\xmp@parse{\global\let\xmp@Publisher\@this}}
 \def\AuthoritativeDomain{\xmp@parse{\global\let\xmp@AuthoritativeDomain\@this}} % currently unused; for backward compatibility
 \let\Creator\CreatorTool  % for backward compatibility
 \let\Org\Publisher        % for backward compatibility
 \let\WebStatement\CopyrightURL  % for backward compatibility
}

%%----------------------------------------------------------------------
%% The following characters and markup can be used within the XMP data
%% defined by \Author, \Title, and so on. 
%%
%% * All printable non-whitespace ASCII characters except
%%   '%', '{', '}', '\' can be used as themselves.
%% 
%% * All printable non-whitespace UTF-8 encoded Unicode characters
%%   from the basic multilingual plane can be used as themselves.
%% 
%% * As usual, consecutive whitespace characters are contracted to a
%%   single space. Whitespace after a macro such as \copyright is
%%   ignored. Blank lines are not permitted. 
%% 
%% * The following markup can be used:
%%   '\ '        - a literal space  (for example after a macro)
%%   \%          - a literal '%'
%%   \{          - a literal '{'
%%   \}          - a literal '}'
%%   \backslash  - a literal '\'
%%   \copyright  - the (c) copyright symbol
%%
%%   \sep        - only permitted within \Author, \Keywords, \Publisher.
%% 
%% * For backward compatibility, \& and \TextCopyright are also
%%   provided. Their use is deprecated.

%%----------------------------------------------------------------------
%% The macro \pdfx@actives binds the active characters
%% '&', '<', and '>' to \pdfx@amp, \pdfx@lt, and \pdfx@gt,
%% respectively, without actually making them active.
\begingroup
 \catcode`\<=13
 \catcode`\>=13
 \catcode`\&=13
 \gdef\pdfx@actives{
  \def&{\pdfx@amp}
  \def<{\pdfx@lt}
  \def>{\pdfx@gt}
 }
\endgroup

%%----------------------------------------------------------------------
%% Markup bindings to be used during XMP generation.

{\obeyspaces\gdef\pdfx@sep{</rdf:li>^^J     <rdf:li>}}

\def\pdfx@xmpmarkup{
 \pdfx@actives
 \edef\@amp{\expandafter\@gobble\string\&}
 \edef\@hash{\expandafter\@gobble\string\#}
 \edef\ {\expandafter\@gobble\string\ }
 \edef\%{\expandafter\@gobble\string\%}
 \edef\{{\expandafter\@gobble\string\{}
 \edef\}{\expandafter\@gobble\string\}}
 \edef\backslash{\expandafter\@gobble\string\\}
 \def\@unicode##1{\@amp\@hash x##1;}
 \def\pdfx@amp{\@unicode{0026}}
 \def\pdfx@lt{\@unicode{003c}}
 \def\pdfx@gt{\@unicode{003e}}
 \def\copyright{\@unicode{00A9}}
 \let\&\pdfx@amp               % for backward compatibility
 \let\TextCopyright\copyright  % for backward compatibility
 \let\sep\pdfx@sep
 \the\pdfxsafeforxmp@toks
}

%% In case macros are used in XMP Metadata, need a way to map these
%% to simple text, rather than specific font characters, or whatever:
\newtoks\pdfxsafeforxmp@toks
\def\pdfxEnableCommands#1{%   user command
 \expandafter\global\expandafter\pdfxsafeforxmp@toks
  \expandafter{\the\pdfxsafeforxmp@toks#1}}

%%----------------------------------------------------------------------
%% Markup bindings to be used during PDF string generation.

\def\pdfx@pdfmarkup{
 \pdfx@actives
 \edef\%{\expandafter\@gobble\string\%}
 \edef\{{\expandafter\@gobble\string\{}
 \edef\}{\expandafter\@gobble\string\}}
 \edef\pdfx@backslash{\expandafter\@gobble\string\\}
 \def\backslash{\pdfx@backslash000\pdfx@backslash134}
 \edef\pdfx@amp{\expandafter\@gobble\string\&}
 \edef\pdfx@lt{\expandafter\@gobble\string\<}
 \edef\pdfx@gt{\expandafter\@gobble\string\>}
 \let\TextCopyright\copyright  % for backward compatibility
 \def\sep{, }
%% Note: '\ ', \&, \copyright are already predefined by hyperref.
 \the\pdfxsafeforxmp@toks
}

%%----------------------------------------------------------------------
%% Defaults

\ifluatex
 \def\xmp@Producer{LuaTeX}
\else
 \def\xmp@Producer{pdfTeX}
\fi
\edef\xmp@CreatorTool{\@pdfcreator}

\global\let\xmp@Title\@empty
\global\let\xmp@Author\@empty
\global\let\xmp@Keywords\@empty
\global\let\xmp@Subject\@empty
\global\let\xmp@Volume\@empty
\global\let\xmp@Issue\@empty
\global\let\xmp@CoverDisplayDate\@empty
\global\let\xmp@CoverDate\@empty
\global\let\xmp@Copyright\@empty
\global\let\xmp@CopyrightURL\@empty
\gdef\xmp@WebStatement{\xmp@CopyrightURL}
\global\let\xmp@Doi\@empty
\global\let\xmp@Lastpage\@empty
\global\let\xmp@Firstpage\@empty
\global\let\xmp@PublicationType\@empty
\global\let\xmp@Journaltitle\@empty
\global\let\xmp@Journalnumber\@empty
\global\let\xmp@Publisher\@empty
\gdef\xmp@Org{\xmp@Publisher}
\global\let\xmp@AuthoritativeDomain\@empty

%%----------------------------------------------------------------------
\def\pdfx@findUUID#1{\edef\pdfx@tmpstring{\pdfx@mdfivesum{#1}}
     \expandafter\pdfx@eightofnine\pdfx@tmpstring\end}
\def\pdfx@eightofnine#1#2#3#4#5#6#7#8#9\end{%
     \xdef\pdfx@eightchars{#1#2#3#4#5#6#7#8}
     \pdfx@fouroffive#9\end}
\def\pdfx@fouroffive#1#2#3#4#5\end{\xdef\pdfx@ffourchars{#1#2#3#4}
     \pdfx@sfouroffive#5\end}
\def\pdfx@sfouroffive#1#2#3#4#5\end{\xdef\pdfx@sfourchars{#1#2#3#4}
     \pdfx@tfouroffive#5\end}
\def\pdfx@tfouroffive#1#2#3#4#5\end{\xdef\pdfx@tfourchars{#1#2#3#4}
     \xdef\pdfx@laststring{#5}}

\def\pdfx@uuid{\pdfx@eightchars-%
          \pdfx@ffourchars-%
          \pdfx@sfourchars-%
          \pdfx@tfourchars-%
          \pdfx@laststring}

\pdfx@findUUID{\jobname.pdf}
\edef\xmp@docid{\pdfx@uuid}
\pdfx@findUUID{\pdfcreationdate}
\edef\xmp@instid{\pdfx@uuid}

%%----------------------------------------------------------------------
%% -----   Color Profiles  -------
%% Define how to specify the profile, so the default
%% can be over-ridden in the  .xmpdata  file.
%%
%%   --- user-command ---   RGB profile needed with  PDF/A-??  files
%%   \setRGBcolorprofile{<filename>}{<identifier>}{<info string>}{<registry URL>}
\def\setRGBcolorprofile{%
 \begingroup
  \catcode`\_ 11\relax\catcode`\& 11\relax\catcode`\~ 11\relax\catcode`\% 11\relax
  \edef\({\string\(}\edef\){\string\)}%
  \pdfx@setrgbprofile}
%%
%%  --- user-command ---   CMYK profile needed with  PDF/X-??  files
%%  \setCMYKcolorprofile{<filename>}{<output intent>}{<identifier>}{<registry URL>}
\def\setCMYKcolorprofile{%
 \begingroup
  \catcode`\_ 11\relax\catcode`\& 11\relax\catcode`\~ 11\relax\catcode`\% 11\relax
  \edef\({\string\(}\edef\){\string\)}%
  \pdfx@setcmykprofile}
%%
%%  --- user-command ---   DeviceGray profile needed with  PDF/E-1  files
%%  \setGRAYcolorprofile{<filename>}{<output intent>}{<identifier>}{<registry URL>}
\def\setGRAYcolorprofile{%
 \begingroup
  \catcode`\_ 11\relax\catcode`\& 11\relax\catcode`\~ 11\relax\catcode`\% 11\relax
  \edef\({\string\(}\edef\){\string\)}%
  \pdfx@setgrayprofile}
%%
%%  --- user-command ---   External profile needed with  PDF/X-4p  and PDF/X-5pg  files
%%  \setEXTERNALprofile{<profilename>}{<output intent>}{<identifier>}{<registry URL>}%
%%    {<color-space>}{<ICC Version>}{<provider URL>}{<extra info>}{<Check Sum>}
\def\setEXTERNALprofile{%
 \begingroup
  \catcode`\_ 11\relax\catcode`\& 11\relax\catcode`\~ 11\relax\catcode`\% 11\relax
  \edef\({\string\(}\edef\){\string\)}%
  \pdfx@externalprofile}
%%
%%
\def\pdfx@setRGBcolorprofiledir#1{%
 \gdef\pdfx@RGBcolorprofiledir{#1}%
}
\def\pdfx@setCMYKcolorprofiledir#1{%
 \gdef\pdfx@CMYKcolorprofiledir{#1}%
}
\pdfx@setRGBcolorprofiledir{}
\pdfx@setCMYKcolorprofiledir{}

%% This does indeed work!  Use it in  .xmpdata  files
\providecommand{\AdobeMacOSdir}{/Library/Application Support/Adobe/Color/Profiles/Recommended/}
\edef\pdfx@tmp{C:\string\Windows\string\System32\string\Spool\string\Drivers\string\Color\string/}
\expandafter\providecommand\expandafter{\expandafter\WindowsColordir\expandafter}\expandafter{\pdfx@tmp}
%%\pdfx@setcolorprofiledir{\AdobeMacOSdir}

%% overide that value using the following commands:
\let\pdfxSetCMYKcolorProfileDir\pdfx@setCMYKcolorprofiledir
\let\pdfxSetRGBcolorProfileDir\pdfx@setRGBcolorprofiledir
\let\pdfxSetColorProfileDir\pdfxSetCMYKcolorProfileDir % for back-compatibility
%%
\def\pdfx@setrgbprofile#1#2#3#4{%
 \xdef\pdfx@rgb@profile{\pdfx@RGBcolorprofiledir#1}%  valid file name
 \gdef\pdfx@rgb@identifier{#2}%
 \gdef\pdfx@rgb@info{#3}%
 \pdfstringdef\pdfx@rgb@registry{#4}%  valid URL
 \endgroup}%  closes-off  \setRGBcolorprofile
%%
\def\pdfx@setcmykprofile#1#2#3#4{%
 \xdef\pdfx@cmyk@profile{\pdfx@CMYKcolorprofiledir#1}%  valid file name
%% \expandafter\gdef\expandafter\pdfx@cmyk@profile\expandafter{\pdfx@colorprofiledir#1}%  valid file name
 \gdef\pdfx@cmyk@intent{#2}%
%% \pdfstringdef\pdfx@cmyk@intent{#2}%  color intent
 \gdef\pdfx@cmyk@identifier{#3}%
%% \pdfstringdef\pdfx@cmyk@identifier{#3}%  text string identifier
 \gdef\pdfx@cmyk@registry{#4}%
%% \pdfstringdef\pdfx@cmyk@registry{#4}%  valid URL
 \endgroup}%  closes-off  \setCMYKcolorprofile
%%
\def\pdfx@setgrayprofile#1#2#3#4{%
 \gdef\pdfx@gray@profile{#1}%  valid file name
 \gdef\pdfx@gray@intent{#2}%
 \gdef\pdfx@gray@identifier{#3}%
 \pdfstringdef\pdfx@gray@registry{#4}%  valid URL
 \endgroup}%  closes-off  \setGRAYcolorprofile
%%
\def\pdfx@externalprofile#1#2#3#4#5#6#7#8#9{%
 \gdef\pdfx@extprofile{#1}% PDF string for /ProfileName 
 \gdef\pdfx@cmyk@intent{#2}% PDF string for /OutputCondition
 \gdef\pdfx@cmyk@identifier{#3}% PDF string for /OutputConditionIdentifier
 \gdef\pdfx@cmyk@registry{#4}% {http://www.color.org}% 
 \gdef\pdfx@profileCS{#5}%  4 bytes for /ProfileCS
 \gdef\pdfx@iccversion{#6}%  Hex string for /ICCVersion < ... >
 \gdef\pdfx@colorURL{#7}%  URL  
 \gdef\pdfx@cmyk@info{#8}%  for /Info 
 \gdef\pdfx@profile@checksum{#9}%  Hex string for /CheckSum < ... > 
 \endgroup}%  closes-off  \setEXTERNALprofile
%%
%% default color profiles
{\catcode`\_ 12 \catcode`\& 12 \catcode`\~ 12
 \gdef\pdfx@xprofile@cmykdefault{coated_FOGRA39L_argl.icc}
 \gdef\pdfx@aprofile@rgbdefault{sRGB_IEC61966-2-1_black_scaled.icc}
 \gdef\pdfx@eprofile@graydefault{Gray_linear.icc}
 \gdef\pdfx@pprofile@externaldefault{FOGRA39}
}% end of \catcode
\xdef\pdfx@rgb@profile{\pdfx@aprofile@rgbdefault}
\xdef\pdfx@cmyk@profile{\pdfx@xprofile@cmykdefault}
\xdef\pdfx@gray@profile{\pdfx@eprofile@graydefault}
\xdef\pdfx@external@profile{\pdfx@pprofile@externaldefault}

%%----------------------------------------------------------------------
%% License for the file  sRGB_IEC61966-2-1_black_scaled.icc :
%%
%% Copyright International Color Consortium, 2009  -- http://www.color.org/
%%
%% It is hereby acknowledged that the file "sRGB_IEC61966-2-1_black_scaled.icc" 
%% is provided "AS IS" WITH NO EXPRESS OR IMPLIED WARRANTY.
%%
%% Licensing
%%
%% This profile is made available by the International Color Consortium,
%% and may be copied, distributed, embedded, made, used, and sold without
%% restriction. Altered versions of this profile shall have the original
%% identification and copyright information removed and shall not be
%% misrepresented as the original profile.
%%
%% Terms of use
%%
%% To anyone who acknowledges that the file "sRGB_IEC61966-2-1_black_scaled.icc" is provided "AS IS" WITH NO EXPRESS 
%% OR IMPLIED WARRANTY, permission to use, copy and distribute these file for any purpose is hereby granted without fee, 
%% provided that the file is not changed including the ICC copyright notice tag, and that the name of ICC shall not be used 
%% in advertising or publicity pertaining to distribution of the software without specific, written prior permission. 
%% ICC makes no representations about the suitability of this software for any purpose.
%%
%%----------------------------------------------------------------------
{\catcode`\| 14 \catcode`\% 12 \catcode`\_ 12
 \edef\@bchar{\expandafter\@gobble\string\\}|
 \edef\({\string\(}\edef\){\string\)}|
 \begingroup | \endgroup occurs within the macro expansion
\expandafter\pdfx@setrgbprofile\expandafter{sRGB_IEC61966-2-1_black_scaled.icc}|
 {sRGB_IEC61966-2-1_black_scaled}|
 {sRGB IEC61966 v2.1 with black scaling}|
 {http://www.color.org}|
 \begingroup | \endgroup occurs within the macro expansion
\pdfx@setcmykprofile{coated_FOGRA39L_argl.icc}|{FOGRA39L.icc}| coated_FOGRA39L_argl.icc
 {Coated FOGRA39}|
 {FOGRA39 \string\(ISO Coated v2 300%\space \string\(ECI\string\)\string\)}|
 {http://www.argyllcms.com/}|{http://www.color.org}|
 \begingroup | \endgroup occurs within the macro expansion
\pdfx@setgrayprofile{Gray_linear.icc}| 
 {}|
 {Custom}|
 {http://www.freedesktop.org/wiki/OpenIcc}|
\ifno@iccprofile
 \begingroup | \endgroup occurs within the macro expansion
  \pdfx@externalprofile{Coated FOGRA39 \(ISO 12647-2:2004\)}|
   {Offset commercial and specialty printing according to ISO 12647-2:2004 |
    / Amd 1, paper type 1 or 2 \(gloss or matte coated offset, 115 g/m2\), |
    screen frequency 60/cm.}|
   {FOGRA39}{http://www.color.org}{CMYK}{02100000}{http://www.adobe.com}|
   {Coated FOGRA39 \(ISO 12647-2:2004\)}{74FF62F330BF0DBE4495B5720542D511}|
\fi
}% end of \catcode
%%
%%----------------------------------------------------------------------
%% License for the file  coated_FOGRA39L_argl.icc :
%%
%% The zlib/libpng License
%%
%% Copyright (c) 2008 Kai-Uwe Behrmann
%%
%% This software is provided 'as-is', without any express or implied
%% warranty. In no event will the authors be held liable for any damages
%% arising from the use of this software.
%%
%% Permission is granted to anyone to use this software for any purpose,
%% including commercial applications, and to alter it and redistribute
%% it freely, subject to the following restrictions:
%%
%%    1. The origin of this software must not be misrepresented; you
%%    must not claim that you wrote the original software. If you use
%%    this software in a product, an acknowledgment in the product
%%    documentation would be appreciated but is not required.
%%
%%    2. Altered source versions must be plainly marked as such, and
%%    must not be misrepresented as being the original software.
%%
%%    3. This notice may not be removed or altered from any source
%%    distribution.
%%----------------------------------------------------------------------

\newif\ifexternalICCprofiles

\begingroup
%% override unneeded color-profile specifier
 \ifpdfx@x 
  \ifno@iccprofile %  PDF/X-4p  and  PDF/X-5pg  PDF/VT-2
   \begingroup 
    \def\pdfx@extprofiles@store{AdobeExternalProfiles.tex}%
    \InputIfFileExists{\pdfx@extprofiles@store}%
     {\global\externalICCprofilestrue \catcode `\# 12\relax}%
     {\typeout{** pdfx: No file \pdfx@extprofiles@store\space found for PDF/X-4p or PDF/X-5pg}}%
   \endgroup
  \else
   \begingroup 
    \def\pdfx@profiles@store{AdobeColorProfiles.tex}%
    \InputIfFileExists{\pdfx@profiles@store}%
     {\global\externalICCprofilesfalse \catcode `\# 12\relax}%
     {\typeout{** pdfx: No file \pdfx@profiles@store\space found for PDF/X variants}}%
   \endgroup
   \def\setRGBcolorprofile#1#2#3#4{}%
  \fi
 \else
%% load it, in case the macros are used in .xmpdata
  \InputIfFileExists{AdobeColorProfiles.tex}{}{}%
  \ifpdfx@e 
  \else
   \def\setCMYKcolorprofile#1#2#3#4{}%
   \def\setGRAYcolorprofile#1#2#3#4{}%
 \fi\fi
%%
 \ifluatex\else
  \inputencoding{8bit}%
 \fi
 \makeatletter
 \pdfx@localcommands
%%
 \InputIfFileExists{\jobname.xmpdata}%
  {\typeout{** pdfx: Metadata file  \jobname.xmpdata  read successfully.}}%
  {\typeout{** pdfx: No file  \jobname.xmpdata . Metadata will be incomplete!}}
\endgroup

%% ----------------------------------------------------------------------
\newif\ifpdfx@cmyk
\begingroup
\ifpdfx@x   %  PDF/X  needs a CMYK color profile for printing
 \global\pdfx@cmyktrue
 \edef\@pctchar{\expandafter\@gobble\string\%}
 \edef\@bchar{\expandafter\@gobble\string\\}
 \edef\0{\string\0}
 \edef\({\string\(}
 \edef\){\string\)}
 \catcode`\_ 12 
 \ifno@iccprofile %  PDF/X-4p  and  PDF/X-5pg
   \immediate\pdfobj {<</FS/URL/F(\pdfx@colorURL)>>} 
   \edef\OBJ@URLs{\the\pdflastobj}%
%%   \xdef\pdfx@cmyk@intent{Offset commercial and specialty printing according to ISO 12647-2:2004 / Amd 1, %
%%    paper type 1 or 2 \(gloss or matte coated offset, 115 g/m2\), screen frequency 60/cm.0}%
%%   \xdef\pdfx@cmyk@info{Coated FOGRA39 \(ISO 12647-2:2004\)}%
%%   \xdef\pdfx@cmyk@name{Coated FOGRA39 \(ISO 12647-2:2004\)}%
%%   \xdef\pdfx@cmyk@identifier{FOGRA39}%
   \immediate\pdfobj {<<%
     /CheckSum <\pdfx@profile@checksum>^^J%
     /ICCVersion <\pdfx@iccversion>%
     /ProfileCS (\pdfx@profileCS)^^J%
     /ProfileName (\pdfx@extprofile)^^J%  
     /URLs [\OBJ@URLs\space 0 R ]
    >>} %
  \edef\OBJ@ICC{\the\pdflastobj}%
%%  \IfFileExists{\pdfx@rgb@profile}{%
%%   \immediate\pdfobj stream attr{/N 3^^J /Alternate /DeviceRGB} file{\pdfx@rgb@profile}%
%%   \edef\OBJ@RGB{\the\pdflastobj}%
%%  }{%
%%   \errmessage{No color profile found to use for RGB screen colors.}%
%%  }%
  \pdfcatalog{%
   /OutputIntents [ <<
   /Type/OutputIntent
   /S/GTS_PDFX
   /OutputCondition (\pdfx@cmyk@intent)%
   /OutputConditionIdentifier (\pdfx@cmyk@identifier)%
   /Info(\pdfx@cmyk@intent)%
   /RegistryName(\pdfx@cmyk@registry)
%% extra dictionary required for PDF/X-4p and  PDF/X-5pg
   /DestOutputProfileRef \OBJ@ICC\space 0 R 
  >> ]}%
%%
 \else  %  PDF/X-1 , PDF/X-1a , PDF/X-3 , PDF/X-4 , PDF/X-5g
%%
  \IfFileExists{"\pdfx@cmyk@profile"}{%
  %  embedded CMYK color profile
  \immediate\pdfobj stream attr{/N 4} file{"\pdfx@cmyk@profile"}%
  \edef\OBJ@CMYK{\the\pdflastobj}%
  \pdfcatalog{%
   /OutputIntents [ <<
   /Type/OutputIntent
   /S/GTS_PDFX
   /OutputCondition (\pdfx@cmyk@intent)%
   /OutputConditionIdentifier (\pdfx@cmyk@identifier)%
   /Info(\pdfx@cmyk@intent)%
   /RegistryName(\pdfx@cmyk@registry)
   /DestOutputProfile \OBJ@CMYK\space 0 R 
  >> ]}%
 }{%
  \errmessage{No color profile \pdfx@cmyk@profile\ found to use for CMYK printing colors.}%
 }%
 \fi % end of  \ifno@iccprofile
\else
%%  PDF/A  and  PDF/E  can specify a CMYK profile 
 \expandafter\ifx\expandafter\relax\pdfx@rgb@profile\relax
  \global\pdfx@cmyktrue
  \IfFileExists{"\pdfx@cmyk@profile"}{%
  %  embedded CMYK color profile
  \immediate\pdfobj stream attr{/N 4} file{"\pdfx@cmyk@profile"}%
  \edef\OBJ@CMYK{\the\pdflastobj}%
  \pdfcatalog{%
   /ViewerPreferences <</DisplayDocTitle true >>
   /OutputIntents [ <<
   /Type /OutputIntent
   \ifpdfx@e
    /S/ISO_PDFE1
   \else
    /S/GTS_PDFA1
   \fi
   /OutputCondition (\pdfx@cmyk@intent)%  use this or  /Info ?
   /OutputConditionIdentifier (\pdfx@cmyk@identifier)%
   /DestOutputProfile \OBJ@CMYK\space 0 R 
   /Info(\pdfx@cmyk@intent)%
   /RegistryName(\pdfx@cmyk@registry)
  >> ]}%
 }{%
  \errmessage{No color profile \pdfx@cmyk@profile\ found to use for CMYK screen colors.}%
 }% 
 \else 
%%  PDF/A and  PDF/E usually need an RGB color profile for on-screen rendering
 \global\pdfx@cmykfalse
 \IfFileExists{"\pdfx@rgb@profile"}{%
  \immediate\pdfobj stream attr{/N 3^^J/Alternate/DeviceRGB} file{"\pdfx@rgb@profile"}%
  \edef\OBJ@RGB{\the\pdflastobj}%
  \pdfcatalog{%
   /ViewerPreferences <</DisplayDocTitle true >>
   /OutputIntents [ <<
   /Type /OutputIntent
   \ifpdfx@e
    /S/ISO_PDFE1
   \else
    /S/GTS_PDFA1
   \fi
   /OutputConditionIdentifier (\pdfx@rgb@identifier)%
   /DestOutputProfile \OBJ@RGB\space 0 R
   /Info(\pdfx@rgb@info)
   /RegistryName(\pdfx@rgb@registry)
  >> 
 ]}%
 }{%
  \errmessage{No color profile found to use for RGB screen colors.}%
 }%
 \fi % end of \ifx
\fi % end of  \ifpdfx@x
\endgroup

%% ----------------------------------------------------------------------
%% Make a version of \xmp@Keywords and \xmp@Author where \sep has been
%% replaced by a comma. The first is for the pdf:Keywords property,
%% which accepts a comma-separated string of keywords, and seems to be
%% mandatory for PDF/A-1 compliance. The second is for the dc:creator
%% property. Although it is defined to be a sequence of authors, Adobe
%% Acrobat will in fact ignore and delete all except the first author.
%% Therefore, it's safer to always separate authors by commas.

\begingroup
 \pdfx@xmpmarkup
 \def\sep{, }%
 \ifluatex\else
  \inputencoding{8bit}%
 \fi
 \makeatletter
 \IfFileExists{\pdfx@encodingfile}{%
  \def\cf@encoding{U}\fontencoding{U}%
 }{}%
 \xdef\xmp@@Keywords{\xmp@Keywords}
 \xdef\xmp@@Author{\xmp@Author}
 \xdef\xmp@@Copyright{\xmp@Copyright}
\endgroup

%% ----------------------------------------------------------------------
\def\xmp@convertDate{\pdfx@getYear}
{\catcode`\D=12 \catcode`\:=12
 \gdef\pdfx@getYear D:#1#2#3#4{\edef\pdfx@xYear{#1#2#3#4}\pdfx@getMonth}
}
\def\pdfx@getMonth#1#2{\edef\pdfx@xMonth{#1#2}\pdfx@getDay}
\def\pdfx@getDay#1#2{\edef\pdfx@xDay{#1#2}\pdfx@getHour}
\def\pdfx@getHour#1#2{\edef\pdfx@xHour{#1#2}\pdfx@getMin}
\def\pdfx@getMin#1#2{\edef\pdfx@xMin{#1#2}\pdfx@getSec}
\def\pdfx@getSec#1#2{\edef\pdfx@xSec{#1#2}\pdfx@getTZh}
\def\pdfx@getTZh{\futurelet\pdfx@next\pdfx@getTzh@branches}

{\catcode`\@=11 \catcode`\Z=12 \catcode`\+=12 \catcode`\-=12
\gdef\pdfx@getTzh@branches{%
 \ifx\pdfx@next Z\let\pdfx@getTzbranch\pdfx@getTznozone
 \else\ifx\pdfx@next +\let\pdfx@getTzbranch\pdfx@getTzplus
 \else\ifx\pdfx@next -\let\pdfx@getTzbranch\pdfx@getTzminus
 \else\let\pdfx@getTzbranch\pdfx@getTzerror
 \fi\fi\fi \pdfx@getTzbranch }

\catcode`\0=12
\gdef\pdfx@getTznozone Z#1\pdfx@getTzend{%
 \edef\pdfx@xTzh{+00}\edef\pdfx@xTzm{00}}
\gdef\pdfx@getTzplus +#1'#2'#3\pdfx@getTzend{%
 \edef\pdfx@xTzh{+#1}\edef\pdfx@xTzm{#2}%
 \ifx\relax#2\relax\def\pdfx@xTzm{00}\fi}
\gdef\pdfx@getTzminus -#1'#2'#3\pdfx@getTzend{%
 \edef\pdfx@xTzh{-#1}\edef\pdfx@xTzm{#2}%
 \ifx\relax#2\relax\def\pdfx@xTzm{00}\fi}
\expandafter\xmp@convertDate\pdfcreationdate''\pdfx@getTzend
\xdef\pdfx@convDate{\pdfx@xYear\pdfx@xMonth\pdfx@xDay\pdfx@xHour\pdfx@xMin\pdfx@xSec\pdfx@xTzh'\pdfx@xTzm'}%
\xdef\xmp@convDate{\pdfx@xYear-\pdfx@xMonth-\pdfx@xDay T\pdfx@xHour:\pdfx@xMin:\pdfx@xSec\pdfx@xTzh:\pdfx@xTzm}%
}% end of \catcode

%% ----------------------------------------------------------------------
%% \pdfx@topdfstring\toka\tokb: Convert the string in \tokb to a format
%% appropriate for PDF /Info strings, i.e., PDFDoc encoding or UTF-16
%% encoding, and store the result in \toka As a special case, if \tokb
%% is \@empty, set \toka to \@empty.

\def\pdfx@topdfstring#1#2{%
 \ifx#2\@empty
  \global\let#1\empty
 \else
  \begingroup
   \ifluatex\else
    \inputencoding{utf8}%
   \fi
   \hypersetup{pdfencoding=auto}%
   \pdfstringdef#1{#2}%
  \endgroup
 \fi
}

%% Convert the relevant XMP properties to PDF strings, expanding markup
%% (such as \sep, \&, \copyright, etc) in an appropriate way.
\begingroup
 \pdfx@pdfmarkup
 \pdfx@topdfstring\pdfx@Title\xmp@Title
 \pdfx@topdfstring\pdfx@Author\xmp@Author
 \pdfx@topdfstring\pdfx@Subject\xmp@Subject
 \pdfx@topdfstring\pdfx@Keywords\xmp@Keywords
 \pdfx@topdfstring\pdfx@CreatorTool\xmp@CreatorTool
 \pdfx@topdfstring\pdfx@Producer\xmp@Producer
\endgroup

\input glyphtounicode.tex
\input glyphtounicode-cmr.tex
\pdfgentounicode=1

\ifpdfx@x
 {\def\sep{,}%
  \pdfinfo{%   order of these dictionary keys should not matter
   \ifx\pdfx@Author\@empty\else /Author(\pdfx@Author)\fi
   /CreationDate(D:\pdfx@convDate)%
   /Creator(\pdfx@CreatorTool)%
   \ifnum\xmp@Part=1 
     /GTS_PDFXVersion(PDF/X-1\ifnum\xmp@ReleaseDate>2001\xmp@Conformance\fi:\xmp@ReleaseDate)%
   \else
    /GTS_PDFXVersion(PDF/X-\xmp@Part\xmp@Conformance\ifnum\xmp@Part< 4 :\xmp@ReleaseDate\fi)%
   \fi
   \ifnum\xmp@Part < 3 
      /GTS_PDFXConformance(PDF/X-\xmp@Part\xmp@Conformance:\xmp@ReleaseDate)%
   \fi
   \ifpdfx@vt %  support for PDF/VT extensions of  PDF/X-4  and PDF/X-5 
%%     /GTS_PDFVTVersion(PDF/VT-\xmp@vtPart\xmp@vtConformance)%
   \fi
   \ifx\pdfx@Keywords\@empty\else /Keywords(\pdfx@Keywords)\fi
   /ModDate(D:\pdfx@convDate)%
   /Producer(\pdfx@Producer)%
   \ifx\pdfx@Subject\@empty\else /Subject(\pdfx@Subject)\fi
   \ifx\pdfx@Title\@empty\else /Title(\pdfx@Title)\fi
   /Trapped/False%
  }%  end of  PDF/X  info
 }% end of scope for  \sep
\else
 \ifpdfx@e
 {\def\sep{,}%
  \pdfinfo{%   order of these dictionary keys should not matter
   \ifx\pdfx@Author\@empty\else /Author(\pdfx@Author)\fi
   /CreationDate(D:\pdfx@convDate)%
   /Creator(\pdfx@CreatorTool)%
   /GTS_PDFEVersion(PDF/E-1\xmp@Conformance:\xmp@ReleaseDate)%
   \ifx\pdfx@Keywords\@empty\else /Keywords(\pdfx@Keywords)\fi
   /ModDate(D:\pdfx@convDate)%
   /Producer(\pdfx@Producer)%
   \ifx\pdfx@Subject\@empty\else /Subject(\pdfx@Subject)\fi
   \ifx\pdfx@Title\@empty\else /Title(\pdfx@Title)\fi
   /Trapped/False%   
  }%  end of  PDF/E  info
 }% end of scope for  \sep
 \else
 \def\pdfx@confA{a}%
 \def\pdfx@confB{b}%
 \def\pdfx@confU{u}%
 \expandafter\def\expandafter\xmp@conf\expandafter{\csname pdfx@conf\xmp@Conformance\endcsname}%
 \AtBeginDocument{%
  \def\PDF@FinishDoc{%
   \Hy@UseMaketitleInfos
   {\def\sep{, }%
    \pdfinfo{%
     \ifx\pdfx@Title\@empty\else /Title(\pdfx@Title)\fi
     \ifx\pdfx@Author\@empty\else /Author(\pdfx@Author)\fi
     \ifx\pdfx@Subject\@empty\else /Subject(\pdfx@Subject)\fi
     \ifx\pdfx@Keywords\@empty\else /Keywords(\pdfx@Keywords)\fi
      /Creator(\pdfx@CreatorTool)%
     \ifx\@pdfcreationdate\@empty
      /CreationDate(D:\pdfx@convDate)%
     \else
      /CreationDate(\@pdfcreationdate)%
     \fi
     \ifx\@pdfmoddate\@empty
      /ModDate(D:\pdfx@convDate)%
     \else
      /ModDate(\@pdfmoddate)%
     \fi
     /Producer(\pdfx@Producer)%
     /Trapped/False
     /GTS_PDFA1Version (PDF/A-\xmp@Part\xmp@conf:\xmp@ReleaseDate)%
    }%  end of  PDF/A  info
   }% end of scope for  \sep
  }% end of  \PDF@FinishDoc
 }% end of  \AtBeginDocument
\fi\fi

%%----------------------------------------------------------------------
\RequirePackage{xmpincl}
\begingroup
 \ifpdfx@x
  \ifpdfx@vt
   \def\xmp@template{pdfvt}%
  \else
   \def\xmp@template{pdfx}%    formerly  pdfx-1a
  \fi
 \else
  \ifpdfx@e
   \def\xmp@template{pdfe}%
  \else
   \def\xmp@template{pdfa}%
 \fi\fi
%% patch commands from  xmpincl.sty  …
 \def\pdfx@xmpinclStart{% supply byte-order marker
  <?xpacket begin='^^ef^^bb^^be' id='W5M0MpCehiHzreSzNTczkc9d' ?> %
 }%
 \def\pdfx@xmpinclStartAlt{% no byte-order marker
  <?xpacket begin='' id='W5M0MpCehiHzreSzNTczkc9d' ?> %
 }%
 \def\pdfx@xmpinclEnd{%  allow XMP packet to be writable
  <?xpacket end='w'?> %
 }%
 \let\mcs@xmpinclStart\pdfx@xmpinclStart
 \let\mcs@xmpinclStartAlt\pdfx@xmpinclStartAlt
 \ifpdfx@noBOM  % don't use the byte-order marker
  \let\mcs@xmpinclStart\pdfx@xmpinclStartAlt
 \fi
 \let\mcs@xmpinclEnd\pdfx@xmpinclEnd
%% … preventing their redefinition
 \def\newcommand#1#2{}%
%%
%% \def\pdfx@endeval{%
%%  \noexpand \TE@setvaltrue \noexpand \else
%%  \noexpand \TE@setvalfalse \noexpand \fi
%%   \noexpand \TE@negatefalse \noexpand \fi}%
%% \let\TE@endeval\pdfx@endeval
 \ifluatex\else
  \inputencoding{8bit}%
 \fi
 \makeatletter
%% \let\&=\xmpAmp
 \pdfx@xmpmarkup
 \def\cf@encoding{U}\fontencoding{U}%
 \providecommand{\ifnot@empty}[2]{\ifx#1\@empty\relax\else#2\fi}%
%% \catcode `\_ 12
 \obeyspaces%  beware of 128 space characters in the next line -- for padding end of XMP packet
 \gdef\paddingline{                                                                                                                                }%
 \typeout{Using XMP template file: \xmp@template.xmp}%
 \includexmp{\xmp@template}
\endgroup

%%
%% controls the color model and conversions with  xcolor  package
%%
\ifpdfx@cmyk
 \PassOptionsToPackage{xcolor}{cmyk,hyperref}
 \def\pdfx@handlexcolor{\selectcolormodel{cmyk}\convertcolorsUtrue\convertcolorsDtrue}
%%\hypersetup{allbordercolors=black,allcolors=black}%  else link borders use RGB
 \ifpdfx@x\else
  \AtBeginDocument{%
   \def\@linkcolor{0 1 1 0}%
   \def\@anchorcolor{0 0 0 1}%
   \def\@citecolor{1 0 1 0}%
   \def\@filecolor{.5 0 0 .5}%
   \def\@urlcolor{0 1 0 0}%
   \def\@menucolor{0 1 1 0}%
   \def\@runcolor{.5 0 0 .5}%
   \def\@linkbordercolor{0 1 1 0}%
   \def\@citebordercolor{1 0 1 0}%
   \def\@filebordercolor{.5 0 0 .5}%
   \def\@urlbordercolor{1 0 0 0}%
   \def\@menubordercolor{0 1 1 0}%
   \def\@runbordercolor{.7 0 0 .3}%
   \def\Fld@bcolor{0 0 0 0}%
   \def\Fld@bordercolor{0 1 1 0}%
  }
 \fi
\else
 \PassOptionsToPackage{xcolor}{rgb,hyperref}
 \def\pdfx@handlexcolor{\selectcolormodel{rgb}\convertcolorsUtrue\convertcolorsDtrue}
\fi
\@ifpackageloaded{xcolor}{\pdfx@handlexcolor}{%
 \AtBeginDocument{\@ifpackageloaded{xcolor}{\pdfx@handlexcolor}{}}
}


%% disable hyperref options, to prevent changes that will cause an incompatibility
 \Hy@DisableOption{pdfauthor}%
 \Hy@DisableOption{pdftitle}%
 \Hy@DisableOption{pdfsubject}%
 \Hy@DisableOption{pdfcreator}%
 \Hy@DisableOption{pdfcreationdate}%
 \Hy@DisableOption{pdfmoddate}%
 \Hy@DisableOption{pdfproducer}%
 \Hy@DisableOption{pdfkeywords}%
%% once set correctly, don't let this change
 \Hy@DisableOption{pdfa}\let\Hy@pdfafalse\relax\let\Hy@pdfatrue\relax
\endinput
%    \end{macrocode}
% \iffalse
%</package>
% \fi
% \Finale
% \newpage\PrintIndex
% \PrintChanges
% \endinput
