If I understood you correctly, you want to have fields in your PDF document displaying the current author as stated in the file's metadata. Like this, you want to be able to update the document by changing the metadata with an external program, which is easier than manipulating the text directly.
Theoretically, this is possible using PDF forms and Acrobat JavaScript: The hyperref
package is capable of creating fillable forms, and with the insdljs
package, you are able to insert the code to update a field with the document information. (insdljs
is part of the AcroTeX bundle, which is in MiKTeX, but not in TeX Live, so you may have to install it manually.)
A proof of concept:
\documentclass{article}
\usepackage{hyperref}
\usepackage[pdftex]{insdljs}
\OpenAction{/S /JavaScript /JS (this.getField("fullname").value = this.info.author;)}
\hypersetup{pdfauthor={diabonas}}
\begin{document}
\begin{Form}
\TextField[name=fullname]{Name: }
\end{Form}
\end{document}
(pdfauthor
is set so that the form field displays something, you can change the PDF author with an external program to see that it works.)
Result:
However, this approach has two drawbacks:
- The inserted text looks quite different from the surrounding text.
- JavaScript doesn't work in many PDF readers other than Adobe (Reader), so unless you have this program installed and JavaScript activated, you'll get a blank field.
Drawback #1 can be tackled by using the various formatting options described in the hyperref
manual.
To overcome drawback #2, I would suggest a different approach than using the document's metadata to update the text:
Create a PDF document containing a fillable form (this is pretty much the same we already did, but without the JavaScript part):
\documentclass{article}
\usepackage{hyperref}
\begin{document}
\begin{Form}
\TextField[name=fullname]{Name: }
\end{Form}
\end{document}
Create a so-called FDF (Forms Data Format) file containing the information you want to insert into the PDF document. For our minimal example, the file would look like this (replace Firstname Lastname
with the name you want to insert):
%FDF-1.2
%âãÏÓ
1 0 obj
<<
/FDF
<<
/Fields [
<<
/V (Firstname Lastname)
/T (fullname)
>>]
>>
>>
endobj
trailer
<<
/Root 1 0 R
>>
%%EOF
To create a "template" FDF file you can fill yourself, you can use the PDF toolkit pdftk
:
pdftk form.pdf generate_fdf output form.fdf
Now, you can write the prepared FDF file form.fdf
into the original PDF form form.pdf
using pdftk
:
pdftk form.pdf fill_form form.fdf output form-filled.pdf flatten
This may seem more work than the first approach, but as a result, you get a static document that can be viewed by any PDF reader.
Package hyperref
Package hyperref
supports the setting of arbitrary keys in the PDF information dictionary (see manual):
\documentclass{article}
\usepackage{hyperref}
\hypersetup{
pdfinfo={
RecordOffice={my office},
AccessionNumber={42},
}
}
\begin{document}
Hello World.
\end{document}
However, these keys are not standardized, thus most tools will not show them. But you can extract them via a PDF library.
Package hyperxmp
The PDF format also supports XMP (eXtensible Metadata Platform). More keywords are standardized there. See package hyperxmp
of Scott Pakin.
Best Answer
From
pdfx
manual:So you have to put the xmpdata in a separate file. We can do it using
filecontents
:To compile this you may have to download the ICC profile (
ISOcoated_v2_300_bas.ICC
) from here: Color management ISO profile. Simply rename the downloaded file asFOGRA39L.ICC
and save it inpdfx
folder (or inlocaltexmf
folder where tex can find it). A file name data base refreshing will be necessary.As noted by Enrico there is a bug in
pdfx
. The command\Subject
won't work. To counter this simply put (Thanks to Enrico):before
\usepackage[a-1b]{pdfx}