I am trying to add other xmp metadata to a pdf file which is not covered by hyperxmp. I tried to use both hyperxmp and xmpincl. Building the project in TeXnicCenter produces no errors, so I am thinking including and using both packages is okay. But when I extract the xmp file through a java code, the only xmp metadata stored in the xmp file is those created with hyperxmp. Am I doing something wrong, or it is really not possible to use both packages?
-
Welcome to TeX.SX! Usually, we don't put a greeting or a “thank you” in our posts. While this might seem strange at first, it is not a sign of lack of politeness, but rather part of our trying to keep everything very concise. Accepting and upvoting answers is the preferred way here to say “thank you” to users who helped you. – Martin Schröder Oct 20 '13 at 22:17
1 Answers
You can't directly use the packages hyperxmp and xmpincl together in one document, as you'll end up with a PDF file including two incompatible XMP metadata entries. However, you can reuse the XMP code produced by hyperxmp as suggested in the manual:
hyperxmpandxmpinclcan complement each other. An author may want to usehyperxmpto produce a basic set of XMP code, then extract the XMP code from the PDF file with a text editor, augment the XMP code with any metadata not supported byhyperxmp, and usexmpinclto include the modied XMP code in the PDF file.
To facilitate this process a bit, you can create a document metadata.tex where you set all the metadata using hyperxmp and write the resulting XMP code to a file metadata.xmp:
metadata.tex
\documentclass{article}
\usepackage{hyperref}
\usepackage{hyperxmp}
\newwrite\xmpmetadata
\makeatletter
\hyxmp@at@end{%
% Create XMP code and write it to macro \hyxmp@xml
% (cf. hyperxmp.sty, \hyxmp@construct@packet (ll. 847-868))
\gdef\hyxmp@xml{}%
\hyxmp@add@to@xml{%
<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@xmpRights@schema
\hyxmp@dc@schema
\hyxmp@photoshop@schema
\hyxmp@photometa@schema
\hyxmp@xmp@basic@schema
\hyxmp@mm@schema
\hyxmp@add@to@xml{%
___</rdf:RDF>^^J%
</x:xmpmeta>^^J%
}%
% Write content of \hyxmp@xml to file metadata.xmp
\immediate\openout\xmpmetadata=metadata.xmp%
\immediate\write\xmpmetadata{\hyxmp@xml}%
\immediate\closeout\xmpmetadata%
}
\makeatother
% Specify the XMP metadata here
\hypersetup{
pdfauthor={Author},
pdftitle={Title},
pdfcopyright={(c) 2013 by Author}
}
\begin{document}
The purpose of this document is to generate a file \texttt{metadata.xmp} containing XMP metadata.
\end{document}
This will produce a file metadata.xmp, which you can modify according to your needs and include it into your main document afterwards:
document.tex
\documentclass{article}
\usepackage{hyperref}
\usepackage{xmpincl}
\includexmp{metadata}
\begin{document}
This is the main document, using the XMP metadata found in \texttt{metadata.xml}.
\end{document}
- 25,784