[latex3-commits] [git/LaTeX3-latex3-pdfresources] reworking-annot: metadata and outputintents (f44fd7d)
Ulrike Fischer
fischer at troubleshooting-tex.de
Sun Feb 7 23:52:13 CET 2021
Repository : https://github.com/latex3/pdfresources
On branch : reworking-annot
Link : https://github.com/latex3/pdfresources/commit/f44fd7d63f453486f11ea72e74645c44c8234ba6
>---------------------------------------------------------------
commit f44fd7d63f453486f11ea72e74645c44c8234ba6
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date: Sun Feb 7 23:52:13 2021 +0100
metadata and outputintents
>---------------------------------------------------------------
f44fd7d63f453486f11ea72e74645c44c8234ba6
experiments/pdfa-test.tex | 24 +++++++++++++
hyperref-generic.dtx | 21 ++++++++++++
l3pdfmeta.dtx | 87 ++++++++++++++++++++++++++++++++++++++++++++++-
3 files changed, 131 insertions(+), 1 deletion(-)
diff --git a/experiments/pdfa-test.tex b/experiments/pdfa-test.tex
new file mode 100644
index 0000000..0050900
--- /dev/null
+++ b/experiments/pdfa-test.tex
@@ -0,0 +1,24 @@
+\RequirePackage{pdfmanagement}
+\DeclareDocumentMetadata
+ { uncompress,
+ lang=de-DE,
+ standard=A-1b
+ }
+\documentclass{article}
+\usepackage{new-hyperxmp}
+\usepackage[]{hyperref}
+
+
+\hypersetup{
+ pdfproducer=TeX,
+ pdfauthor={Ulrike Fischer},
+ pdftitle={A test of metadata},
+ }
+
+% Kompabilität mit hyperxmf ...
+\makeatletter \Hy at pdfatrue \makeatother
+\kvsetkeys{Hyp} {pdfapart=1,pdfaconformance=b,pdfauthor={Ulrike Fischer},pdfproducer=TeX,pdftitle=A test of metadata}
+
+\begin{document}
+abc
+\end{document}
\ No newline at end of file
diff --git a/hyperref-generic.dtx b/hyperref-generic.dtx
index b48aaa6..18e9c30 100644
--- a/hyperref-generic.dtx
+++ b/hyperref-generic.dtx
@@ -122,6 +122,7 @@
% not as package option.
% \item Colors used in the keys for link colors should be defined after the
% package has been loaded.
+% \item Load a color package or graphicx to get the right page sizes.
% \item Report problems! Only known problem can be resolved.
% \end{itemize}
%
@@ -134,6 +135,26 @@
% so if commands from \pkg{bookmark} are needed in the preamble the document
% should load it manually. This is subject to change at some time in the future.
%
+% \section{\enquote{Metadata}}
+%
+% \enquote{Metadata}, informations about the document, are stored in a PDF in two
+% places: The |/Info| dictionary and the XMP-metadata. \pkg{hyperref} only handles the
+% |/Info| dictionary. The XMP-metadata are created by packages like \pkg{pdfx} and
+% \pkg{hyperxmp}.
+% The |/Info| dictionary can be filled with arbitrary keys, but the PDF viewer typically
+% care only about a few, like author, title and keywords.
+%
+% The handling of the metadata is problematic for two reasons:
+% \begin{itemize}
+% \item External package like \pkg{hyperxmp} want access to them too.
+% \item \pkg {hyperref} tries to deduce this data from document commands like
+% \cs{title} or \cs{author}---something that worked reasonably well when only
+% some standard classes with well-known definitions of these command existed,
+% but gets problematic with classes and packages which try to define
+% more powerful commands with a variety of optional arguments to set authors and
+% affiliations and title information.
+% \end{itemize}
+%
% \section{PDF page size (mediabox)}
% The standard \pkg{hyperref} driver contain code to set the PDF page size.
% There is no real justification why this is done by \pkg{hyperref} apart from the
diff --git a/l3pdfmeta.dtx b/l3pdfmeta.dtx
index d9197aa..28a8240 100644
--- a/l3pdfmeta.dtx
+++ b/l3pdfmeta.dtx
@@ -86,9 +86,10 @@
% \begin{macrocode}
\msg_new:nnn {pdf }{unknown-standard}{The~standard~'#1'~is~unknown~and~has~been~ignored}
% \end{macrocode}
-% \begin{variable}{\l_@@_tmpa_tl}
+% \begin{variable}{\l_@@_tmpa_tl,\l_@@_tmpa_str}
% \begin{macrocode}
\tl_new:N\l_@@_tmpa_tl
+\str_new:N \l_@@_tmpa_str
% \end{macrocode}
% \end{variable}
% \section{XMP-metadata}
@@ -233,6 +234,11 @@
%===============
% to be continued https://docs.verapdf.org/validation/pdfa-part1/
% - Outputintent/colorprofiles requirements
+ % an outputintent should be loaded. There are more requirements
+ % but these are not tested
+ ,outputintent =
+ ,outputintent_subtype = {GTS_PDFA1}
+ ,outputintent_profile = {sRGB.icc}
% - no Alternates key in image dictionaries
% - no OPI, Ref, Subtype2 with PS key in xobjects
% - Interpolate = false in images
@@ -284,6 +290,85 @@
% \end{macrocode}
% \end{variable}
%
+% \subsection{Colorprofiles and Outputintents}
+% The following provides a minimum of interface to add a color profile
+% and an outputintent need for PDF/A for now. There will be need to extend it later,
+% so we try for enough generality.
+%
+% \begin{macrocode}
+\pdfdict_new:n {l_pdfmeta/outputintent}
+\pdfdict_put:nnn {l_pdfmeta/outputintent}
+ {Type}{/OutputIntent}
+\prop_const_from_keyval:cn { c_@@_colorprofile_sRGB.icc}
+ {
+ ,OutputConditionIdentifier=IEC~sRGB
+ ,Info=IEC~61966-2.1~Default~RGB~colour~space~-~sRGB
+ ,RegistryName=http://www.iec.ch
+ ,N = 3
+ }
+\prop_const_from_keyval:cn { c_@@_colorprofile_FOGRA39L_coated.icc}
+ {
+ ,OutputConditionIdentifier=FOGRA39L~Coated
+ ,Info={Offset~printing,~according~to~ISO~12647-2:2004/Amd~1,~OFCOM,~ %
+ paper~type~1~or~2~=~coated~art,~115~g/m2,~tone~value~increase~curves~A~(CMY)~and~B~(K)}
+ ,RegistryName=http://www.fogra.org
+ ,N = 4
+ }
+
+\cs_new_protected:Npn \@@_embed_colorprofile:n #1%#1 file name
+ {
+ \pdf_object_if_exist:nF {@@_colorprofile_#1}
+ {
+ \pdf_object_new:nn {@@_colorprofile_#1}{fstream}
+ \pdf_object_write:nx {@@_colorprofile_#1}
+ {
+ {/N\c_space_tl
+ \prop_item:cn{c_@@_colorprofile_#1}{N}
+ }
+ {#1}
+ }
+ }
+ }
+
+\cs_new_protected:Npn \@@_write_outputintent:nn #1 #2 %#1 file name, #2 subtype
+ {
+ \group_begin:
+ \pdfdict_put:nnx {l_pdfmeta/outputintent}{S}{/\str_convert_pdfname:n{#2}}
+ \pdfdict_put:nnx {l_pdfmeta/outputintent}
+ {DestOutputProfile}
+ {\pdf_object_ref:n{@@_colorprofile_#1}}
+ \clist_map_inline:nn { OutputConditionIdentifier, Info, RegistryName }
+ {
+ \prop_get:cnNT
+ { c_@@_colorprofile_#1}
+ { ##1 }
+ \l_@@_tmpa_tl
+ {
+ \pdf_text_convert:nVN {utf8/string-print}\l_@@_tmpa_tl\l_@@_tmpa_str
+ \pdfdict_put:nnx
+ {l_pdfmeta/outputintent}{##1}{\l_@@_tmpa_str}
+ }
+ }
+ \pdf_object_now:nx {dict}{\pdfdict_use:n {l_pdfmeta/outputintent} }
+ \pdfmanagement_add:nnx {Catalog}{OutputIntents}{\pdf_object_last:}
+ \group_end:
+ }
+
+\AddToHook{begindocument/end}
+ {
+ \prop_if_in:NnTF\g_pdfmeta_standard_prop {outputintent}
+ {
+ \exp_args:Nx
+ \@@_embed_colorprofile:n
+ {\prop_item:Nn \g_pdfmeta_standard_prop {outputintent_profile}}
+ \exp_args:Nxx
+ \@@_write_outputintent:nn
+ {\prop_item:Nn \g_pdfmeta_standard_prop {outputintent_profile}}
+ {\prop_item:Nn \g_pdfmeta_standard_prop {outputintent_subtype}}
+ }
+ }
+% \end{macrocode}
+%
% \begin{macrocode}
%</package>
% \end{macrocode}
More information about the latex3-commits
mailing list.