[latex3-commits] [git/LaTeX3-latex3-pdfresources] verify: colorprofiles (928c9e9)

Ulrike Fischer fischer at troubleshooting-tex.de
Fri Feb 19 00:09:37 CET 2021


Repository : https://github.com/latex3/pdfresources
On branch  : verify
Link       : https://github.com/latex3/pdfresources/commit/928c9e902d2e52d8818fff280d66723571114922

>---------------------------------------------------------------

commit 928c9e902d2e52d8818fff280d66723571114922
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date:   Fri Feb 19 00:09:37 2021 +0100

    colorprofiles


>---------------------------------------------------------------

928c9e902d2e52d8818fff280d66723571114922
 l3pdfmeta.dtx | 141 +++++++++++++++++++++++++++++++++-------------------------
 1 file changed, 81 insertions(+), 60 deletions(-)

diff --git a/l3pdfmeta.dtx b/l3pdfmeta.dtx
index e97d7ef..efe52b6 100644
--- a/l3pdfmeta.dtx
+++ b/l3pdfmeta.dtx
@@ -178,9 +178,11 @@
 %
 % \begin{description}
 %
-% \item[|outputintent|] requires to embed a color profile and
-%  reference it in a /Outputintent.
-%  {\em This requirement is detected and fulfilled by \pkg{l3pdfmeta}, see below}.
+% \item[|outputintent_A|] requires to embed a color profile and
+%  reference it in a /Outputintent and that all output intents reference
+%  the same colorprofile. The value stores the subtype.
+%  {\em This requirement is detected and fulfilled by \pkg{l3pdfmeta} if the
+%   provided interface in \cs{DeclareDocumentMetadata} is used, see below}.
 %
 % \item[|annot_flags|] in annotations the |Print| flag should be true,
 %  |Hidden|, |Invisible|, |NoView| should be false.
@@ -212,9 +214,7 @@
 %  A failure means that the version should be changed.
 %  This check is done by \pkg{l3pdfmeta} when the version is set with
 %  \cs{DeclareDocumentMetadata} so more checks are only needed if the version is changed later.
-% \item[|outputintent_subtype|] this requirement stores allowed
-% names for the |/Outputintent| subtype  like |GTS_PDFA1|.
-% This value is typically only read.
+%
 % \item[|named_actions|]    this requirement restricts the list of
 % allowed named actions to |NextPage|, |PrevPage|, |FirstPage|, |LastPage|.
 % The check should supply the named action without slash
@@ -236,9 +236,9 @@
 % should all reference the same color profile\footnote{see rule 6.2.2-2 at
 % \url{https://docs.verapdf.org/validation/pdfa-part1/}}.
 %
-% Enforcing this fully is impossible as it is difficult to inspect
-% and remove entries from the |/OutputIntent| added manually by users or packages with
-% |\pdfmanagement_add:nnn {Catalog}{OutputIntents}{|\meta{object reference}|}|.
+% Enforcing this fully is impossible if entries are added manually by users or
+% packages with |\pdfmanagement_add:nnn {Catalog}{OutputIntents}{|\meta{object reference}|}|
+% as it is difficult to inspect and remove entries from the |/OutputIntent| array.
 %
 % So we provide a dedicated interface to avoid the need of manual
 % user settings and allow the code to handle the requirements of the standard.
@@ -315,9 +315,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,\l_@@_tmpa_str}
+% \begin{variable}{\l_@@_tmpa_tl,\l_@@_tmpb_tl,\l_@@_tmpa_str}
 %    \begin{macrocode}
 \tl_new:N\l_@@_tmpa_tl
+\tl_new:N\l_@@_tmpb_tl
 \str_new:N \l_@@_tmpa_str
 %    \end{macrocode}
 % \end{variable}
@@ -522,12 +523,8 @@
     %===============
     % to be continued https://docs.verapdf.org/validation/pdfa-part1/
     % - Outputintent/colorprofiles requirements
-    % an outputintent should be loaded.
-    ,outputintent          =
-    % its subtype:
-    ,outputintent_subtype  = {GTS_PDFA1}
-    % only one (A) profile
-    ,outputintent_unique   =
+    % an outputintent should be loaded and is unique.
+    ,outputintent_A         = {GTS_PDFA1}
     % - no Alternates key in image dictionaries
     % - no OPI, Ref, Subtype2 with PS key in xobjects
     % - Interpolate  = false in images
@@ -616,28 +613,43 @@
  {
    ,A .code:n =
       {
-        \prop_gput:Nnn \g_@@_outputintents_prop
-          { GTS_PDFA1  } {#1}
+        \tl_if_blank:nF
+          {
+            \prop_gput:Nnn \g_@@_outputintents_prop
+             { GTS_PDFA1  } {#1}
+          }
       }
    ,a .code:n =
       {
-        \prop_gput:Nnn \g_@@_outputintents_prop
-          { GTS_PDFA1  } {#1}
+        \tl_if_blank:nF
+          {
+            \prop_gput:Nnn \g_@@_outputintents_prop
+              { GTS_PDFA1  } {#1}
+          }
       }
-   X .code:n =
+   ,X .code:n =
       {
-        \prop_gput:Nnn \g_@@_outputintents_prop
-          { GTS_PDFX  } {#1}
+        \tl_if_blank:nF
+          {
+             \prop_gput:Nnn \g_@@_outputintents_prop
+              { GTS_PDFX  } {#1}
+          }
       }
-   x .code:n =
+   ,x .code:n =
       {
-        \prop_gput:Nnn \g_@@_outputintents_prop
-          { GTS_PDFX  } {#1}
+        \tl_if_blank:nF
+          {
+            \prop_gput:Nnn \g_@@_outputintents_prop
+              { GTS_PDFX  } {#1}
+          }
       }
-  unknown .code:n =
+   ,unknown .code:n =
      {
-       \prop_gput:Nxn \g_@@_outputintents_prop
-          { \l_keys_key_str  } {#1}
+       \tl_if_blank:nF
+          {
+            \prop_gput:Nxn \g_@@_outputintents_prop
+              { \l_keys_key_str  } {#1}
+          }    
      }
  }
 %    \end{macrocode}
@@ -699,48 +711,57 @@
      \pdfmanagement_add:nnx {Catalog}{OutputIntents}{\pdf_object_ref_last:}
     \group_end:
   }
+%    \end{macrocode}
+% Now the verifying code.
+% If no requirement is set we simply loop over the property
+%    \begin{macrocode}
 
 \AddToHook{begindocument/end}
   {
-    \pdfmeta_standard_verify:nF {outputintent}
+    \pdfmeta_standard_verify:nTF {outputintent_A}
       {
-        \exp_args:NNx
-         \prop_if_in:NnF \g_@@_outputintents_prop
-           {
-             \pdfmeta_standard_item:n {outputintent_subtype}
-           }
+         \prop_map_inline:Nn \g_@@_outputintents_prop
            {
-             \prop_gput:Nxn { \pdfmeta_standard_item:n {outputintent_subtype} }{sRGB.icc}
+             \exp_args:Nx
+               \@@_embed_colorprofile:n
+                 {#2}
+             \exp_args:Nxx
+               \@@_write_outputintent:nn
+                 {#2}
+                 {#1}
            }
       }
-    \pdfmeta_standard_verify:nTF {outputintent_unique}
-      {
-       \prop_map_inline:Nn \g_@@_outputintents_prop
-         {
-           \exp_args:Nx
-             \@@_embed_colorprofile:n
-              {\prop_item:Nn \g_@@_outputintents_prop {#2}}
-           \exp_args:Nxx
-             \@@_write_outputintent:nn
-              {#2}
-              {#1}
-         }
-      }
+%    \end{macrocode}
+% If an outputintent is required for pdf/A we need to ensure, that the key of
+% default subtype has a value, as default we take sRGB.icc.
+% Then we loop but take always the same profile.
+%    \begin{macrocode}
       {
-        \exp_args:Nx
-          \@@_embed_colorprofile:n
-            {\prop_item:Nn \g_@@_outputintents_prop {GTS_PDFA1}}
+        \exp_args:NNx
+         \prop_if_in:NnF \g_@@_outputintents_prop
+            { \pdfmeta_standard_item:n { outputintent_A } }
+            {
+              \exp_args:NNx
+              \prop_gput:Nnn \g_@@_outputintents_prop
+                { \pdfmeta_standard_item:n { outputintent_A } }
+                { sRGB.icc }
+            }
+         \exp_args:NNx
+           \prop_get:NnN \g_@@_outputintents_prop
+             { \pdfmeta_standard_item:n { outputintent_A } }
+             \l_@@_tmpb_tl
+        \exp_args:NV \@@_embed_colorprofile:n \l_@@_tmpb_tl
         \prop_map_inline:Nn \g_@@_outputintents_prop
-           {
-             \exp_args:Nxx
-               \@@_write_outputintent:nn
-                {#2}
-                {GTS_PDFA1}
-          }
-      }
+            {
+              \exp_args:NV
+                \@@_write_outputintent:nn
+                  \l_@@_tmpb_tl
+                  { #1 }
+            }
+       }
    }
 %    \end{macrocode}
-
+%
 %    \begin{macrocode}
 %</package>
 %    \end{macrocode}





More information about the latex3-commits mailing list.