[latex3-commits] [git/LaTeX3-latex3-pdfresources] renamedict77: file embedding, seems to work (86f9282)

Ulrike Fischer fischer at troubleshooting-tex.de
Fri Apr 24 17:26:53 CEST 2020


Repository : https://github.com/latex3/pdfresources
On branch  : renamedict77
Link       : https://github.com/latex3/pdfresources/commit/86f9282735d575c61eb344b03959204e95a83f3b

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

commit 86f9282735d575c61eb344b03959204e95a83f3b
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date:   Fri Apr 24 17:26:53 2020 +0200

    file embedding, seems to work


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

86f9282735d575c61eb344b03959204e95a83f3b
 experiments/embedfiles.tex | 122 ++++++++++++++------
 l3pdffile.dtx              | 275 +++++++++++++++++++++++++++++++++------------
 pdfresources.dtx           | 132 ++++++++++++++++------
 3 files changed, 394 insertions(+), 135 deletions(-)

diff --git a/experiments/embedfiles.tex b/experiments/embedfiles.tex
index 28f8122..7570686 100644
--- a/experiments/embedfiles.tex
+++ b/experiments/embedfiles.tex
@@ -1,48 +1,104 @@
 % !Mode:: "TeX:UTF-8:Main"
 \documentclass{article}
-\usepackage{pdfresources,l3pdffile}
+\usepackage{pdfresources}
+\usepackage{l3pdffile}
 \usepackage{hyperref}
 \ExplSyntaxOn
 \pdf_uncompress:
 \ExplSyntaxOff
 \begin{document}
-\subsection{n}
-\section{a}
+\section{Testing embedding and attaching files}
 \ExplSyntaxOn
-\file_parse_full_name:nNNN {example-image.pdf}\l_tmpa_tl\l_tmpb_tl\l__pdf_file_ext_tl
-\tl_show:N \l__pdf_file_ext_tl
-\tl_show:N \l_tmpb_tl
-\tl_show:N \l_tmpa_tl
-\file_if_exist:nTF {example-image.pdf}{true}{false}
-\file_if_exist:nTF {new-attachfile}
-{\g_file_curr_ext_str, \g_file_curr_name_str}
-{blub}
-
-\tl_new:N\l_file_a_tl
-\tl_new:N\l_file_b_tl
-\par
-\pdfdict_get:nnN {file}{Subtype}\l_tmpa_tl
-\quark_if_no_value:NTF \l_tmpa_tl {nosubtype}{subtype}\par
-\pdfdict_put:nnn {file}{Subtype}{\pdftool_name:n{application/postscript}}
-\pdfdict_get:nnN {file}{Subtype}\l_tmpa_tl\par
-\pdfdict_remove:nn {file}{Subtype}
-\pdfdict_get:nnN {file}{Subtype}\l_tmpa_tl\par
-\quark_if_no_value:NTF \l_tmpa_tl {nosubtype}{subtype}
-
-\pdfdict_put:nnn {file/FileSpec} {AFRelationship}{/Source}
-\pdfdict_put:nnn {file/FileSpec} {Desc}{(this~is~a~description)}
-
-\pdffile_embed:nN       {example-image.eps}\l_tmpa_tl
-\pdffile_embed_spec:nnN {example-image.eps}{\l_tmpa_tl}\l_file_a_tl
+\showoutput
+\cs_new_protected:Npn \__pdf_backend_object_write_fstream:nn #1#2
+  {
+    \exp_args:Nx
+      \__pdf_backend_object_write_fstream:nnn {#1} #2
+  }
 
-\pdfdict_put:nnn       {file}{Subtype}{\pdftool_name:n{text/plain}}
-\pdfdict_put:nnn       {file/FileSpec} {AFRelationship}{/Data}
-\pdfdict_put:nnn       {file/FileSpec} {Desc}{(this~is~another~description)}
-\pdffile_embed:nN       {testinput.txt}\l_tmpa_tl
-\pdffile_embed_spec:nnN {testinput.txt}{\l_tmpa_tl}\l_file_b_tl
+\cs_new_protected:Npn \__pdf_backend_object_write_fstream:nnn #1#2#3
+  {
+   \tl_set:Nn\l_tmpa_tl {#3}\show\l_tmpa_tl
+
+    \__kernel_backend_postscript:x
+      {
+        %[nobreak]
+        ~
+        mark ~ #1 ~ << #2 >> /PUT ~ pdfmark ~
+        mark ~ #1 ~ ( #3 )~ (r)~ file ~ /PUT ~ pdfmark ~
+      }
+  }
 
+%\%cs_set_protected:Npn \pdffile_embed:nn #1 #2
+% % #1 symbolic object name of file spec  #2 file name,
+%  {
+%    \file_get_full_name:nNF {#2} \l_pdffile_full_name_str
+%     {
+%        \msg_error:nnn { pdffile }{ file-not-found }{ #2 }
+%     }
+%    %we need the extension
+%    \file_parse_full_name:VNNN
+%      \l_pdffile_full_name_str
+%      \l_tmpa_tl
+%      \l_tmpb_tl
+%      \l__pdf_file_ext_str
+%    %check if Subtype has been set
+%    \pdfdict_get:nnN {file}{Subtype}\l__pdf_file_tmpa_tl
+%    \quark_if_no_value:NT \l__pdf_file_tmpa_tl
+%      {
+%        \prop_get:NVNTF \g_pdffile_mimetypes_prop \l__pdf_file_ext_str \l_tmpa_tl
+%          {
+%            \tl_set:Nx \l__pdf_file_subtype_tl {/Subtype~\pdftool_name:V \l_tmpa_tl}
+%           }
+%          {
+%            \tl_clear:N \l__pdf_file_subtype_tl
+%            \msg_warn:nnn { pdffile }{ mimetype-missing} { #2 }
+%          }
+%      }
+%    \pdf_object_now:nx { fstream }
+%      {
+%        {
+%          \l__pdf_file_subtype_tl
+%          \pdfdict_map:n {file}
+%          \pdfdict_if_empty:nF {file/Params}
+%            {
+%              /Params
+%                <<
+%                  \pdfdict_map:n {file/Params}
+%                >>
+%            }
+%        }
+%        { \l_pdffile_full_name_str }
+%      }
+%%    \tl_clear:N \l__pdf_file_subtype_tl
+%%    \tl_set:Nx  \l__pdf_file_object_last_tl {\pdf_object_last:}
+%%    \pdf_object_new:nn   { #1 } {dict}
+%%    \pdf_object_write:nx { #1 }
+%%      {
+%%        \pdfdict_map:n {file/FileSpec}
+%%        /EF <</F~\l__pdf_file_object_last_tl /UF~\l__pdf_file_object_last_tl>>
+%%      }
+%  }
+
+\pdfdict_put:nnn  {file/FileSpec} {AFRelationship}{/Source}
+\pdfdict_put:nnn  {file/FileSpec} {Desc}{(this~is~a~eps)}
+\pdffile_embed:nn {example}{example-imageX.eps}
+\pdffile_attach:n {example}
+%
+\pdfdict_put:nnn  {file/FileSpec} {AFRelationship}{/Data}
+\pdfdict_put:nnn  {file/FileSpec} {Desc}{(this~is~a~text~file)}
+\pdffile_embed:nn {test} {testinput.txt}
+\pdffile_attach:n {test}
+%
+\pdfdict_put:nnn  {file/FileSpec} {AFRelationship}{/Source}
+\pdfdict_put:nnn  {file/FileSpec} {Desc}{(this~is~a~tex~file)}
+\pdffile_embed:nn {tex} {links.tex}
+\pdffile_attach:nN {tex}\l_tmpa_tl
 
+%\tl_show:N\l_tmpa_tl
+\ExplSyntaxOff
 
+\end{document}
 %\pdf_object_new:nn  {myfilespec}{dict}
 %\pdf_object_write:nx {myfilespec}
 % {
diff --git a/l3pdffile.dtx b/l3pdffile.dtx
index f421cd4..9f06cf9 100644
--- a/l3pdffile.dtx
+++ b/l3pdffile.dtx
@@ -220,6 +220,35 @@
 %    \begin{macrocode}
 %<@@=pdf>
 %    \end{macrocode}
+%    \begin{macrocode}
+% https://github.com/latex3/latex3/issues/711
+\prg_new_conditional:Npnn \__pdf_backend_object_if_exist:n #1 { p , T , F , TF }
+  {
+    \int_if_exist:cTF { c__pdf_backend_object_ \tl_to_str:n {#1} _int }
+     { \prg_return_true: }
+     { \prg_return_false:}
+  }
+
+\prg_new_eq_conditional:NNn \pdfobject_if_exist:n\__pdf_backend_object_if_exist:n
+  { TF , T , F , p }
+%    \end{macrocode}
+% \subsection{Messages}
+%    \begin{macrocode}
+\msg_new:nnn { pdffile } { file-not-found }
+  {
+    File~'\tl_to_str:n{#1}'~not~found
+  }
+
+\msg_new:nnn { pdffile } { mimetype-missing }
+  {
+    Mime~type~not~set~for~file~'\tl_to_str:n{#1}'
+  }
+
+\msg_new:nnn { pdffile } { file-object-no-found }
+  {
+    file~object~'\tl_to_str:n{#1}'~is~not~declared
+  }
+%    \end{macrocode}
 % \begin{variable}
 %   {
 %     \l_@@_file_tmpa_tl,
@@ -296,99 +325,207 @@
 % these macros must be combined ...
 % \begin{macro}{\pdffile_embed:nN}
 %    \begin{macrocode}
+
+
 \cs_new_protected:Npn \pdffile_embed:nn #1 #2
- %#1 symbolic object name of file spec  #2 file name,
+ % #1 symbolic object name of file spec  #2 file name,
   {
-    \file_get_full_name:nNF  \l_pdffile_full_name_str { #2 }
-     {
-        %error message
-     }
-    \file_parse_full_name:VNNN
-      \l_pdffile_full_name_str
-      \l_tmpa_tl \l_tmpb_tl \l_@@_file_ext_str
-    %check if Subtype has been set
-    \pdfdict_get:nnN {file}{Subtype}\l_@@_file_tmpa_tl
-    \quark_if_no_value:NT \l_@@_file_tmpa_tl
-      {
-        \prop_get:NVNTF \g_pdffile_mimetypes_prop \l_@@_file_ext_tl \l_tmpa_tl
-          {
-            \tl_set:Nx \l_@@_file_subtype_tl {/Subtype~\pdftool_name:V \l_tmpa_tl}
-           }
-          {
-            \tl_clear:N \l_@@_file_subtype_tl
-          }
-      }
-    \pdf_object_now:nx { fstream }
+    \file_get_full_name:nNTF {#2} \l_pdffile_full_name_str
       {
+      %we need the extension
+      \file_parse_full_name:VNNN
+        \l_pdffile_full_name_str
+        \l_tmpa_tl
+        \l_tmpb_tl
+        \l_@@_file_ext_str
+      %check if Subtype has been set
+      \pdfdict_get:nnN {file}{Subtype}\l_@@_file_tmpa_tl
+      \quark_if_no_value:NT \l_@@_file_tmpa_tl
         {
-          \l_@@_file_subtype_tl
-          \pdfdict_map:n {file}
-          \pdfdict_if_empty:nF {file/Params}
+          \prop_get:NVNTF \g_pdffile_mimetypes_prop \l_@@_file_ext_str \l_tmpa_tl
+            {
+              \tl_set:Nx \l_@@_file_subtype_tl {/Subtype~\pdftool_name:V \l_tmpa_tl}
+             }
             {
-              /Params
-              <<
-                \pdfdict_map:n {file/Params}
-              >>
+              \tl_clear:N \l_@@_file_subtype_tl
+              \msg_warning:nnn { pdffile }{ mimetype-missing} { #2 }
             }
         }
-        { \l_pdffile_full_name_str }
-      }
-    \tl_clear:N \l_@@_file_subtype_tl
-    \tl_set:Nx \l_@@_file_object_last_tl {\pdf_object_last:}
-    \pdf_object_new:nn   { #1 } {dict}
-    \pdf_object_write:nx { #1 }
-      {
-        \pdfdict_map:n {file/FileSpec}
-        /EF <</F~\l_@@_file_object_last_tl /UF~\l_@@_file_object_last_tl>>
-      }
+      \pdf_object_now:nx { fstream }
+        {
+          {
+            \l_@@_file_subtype_tl
+            \pdfdict_map:n {file}
+            \pdfdict_if_empty:nF {file/Params}
+              {
+                /Params
+                  <<
+                    \pdfdict_map:n {file/Params}
+                  >>
+              }
+          }
+          { \l_pdffile_full_name_str }
+        }
+      \tl_clear:N \l_@@_file_subtype_tl
+      \tl_set:Nx  \l_@@_file_object_last_tl {\pdf_object_last:}
+      \pdf_object_new:nn   { #1 } {dict}
+      \pdf_object_write:nx { #1 }
+        {
+          \pdfdict_map:n {file/FileSpec}
+          /EF <</F~\l_@@_file_object_last_tl /UF~\l_@@_file_object_last_tl>>
+        }
+     }
+     {
+        \msg_error:nnn { pdffile }{ file-not-found }{ #2 }
+     }
   }
 %    \end{macrocode}
 % \end{macro}
-%
-^^A% \begin{macro}{\pdffile_spec:nN}
-^^A%    \begin{macrocode}
-^^A\cs_new_protected:Npn \pdffile_spec:nN #1 #2
-^^A  {
-^^A    \tl_set:Nn \l_pdffile_full_name_str {#1}
-^^A    \pdf_object_now:nx {dict}
-^^A      {
-^^A        \pdfdict_map:n {file/FileSpec}
-^^A      }
-^^A    \tl_set:Nx #2 {\pdf_object_last:}
-^^A  }
-^^A%    \end{macrocode}
-^^A% \end{macro}
-%
-% \begin{macro}{\pdffile_embed_spec:nnN}
+
+% \subsection{backend commands to add the file to the /EmbeddedFiles name tree}
+% For pdflatex, lualatex and xelatex, the name and object reference is stored in a sequence.
+% The pdfresources code for the catalog output this and add a reference to /Names,
+% if the sequence is not empty.
+% dvips wants code for every file and then sorts this it self.
 %    \begin{macrocode}
-\int_new:N \g_@@_file_embedname_int
-\seq_new:N \g_@@_file_embednames_seq
-\cs_new:Npn \@@_file_embedname:
+\int_new:N \g_@@_file_tree_name_int
+% \seq_new:N \g_@@_file_tree_name_seq %moved to resource file, to the push command
+\cs_new:Npn \@@_file_tree_name:
  {
    (
     l3ef
-    \int_compare:nNnT {\g_@@_file_embedname_int} < {10}
+    \int_compare:nNnT {\g_@@_file_tree_name_int} < {10}
      {0}
-    \int_compare:nNnT {\g_@@_file_embedname_int} < {100}
+    \int_compare:nNnT {\g_@@_file_tree_name_int} < {100}
      {0}
-    \int_compare:nNnT {\g_@@_file_embedname_int} < {1000}
+    \int_compare:nNnT {\g_@@_file_tree_name_int} < {1000}
      {0}
-    \int_use:N \g_@@_file_embedname_int
+    \int_use:N \g_@@_file_tree_name_int
    )
  }
 
-\cs_new_protected:Npn \pdffile_embed_spec:nnN #1 #2 #3 %#1 file name, #2 stream ref, #3tlvar
+\bool_if:nT %pdftex,luatex,xetex
+  {
+    ( \sys_if_engine_pdftex_p: && \sys_if_output_pdf_p: ) %
+    ||
+     \sys_if_engine_luatex_p:
+    ||
+     \sys_if_engine_xetex_p:
+  }
+ {
+  \cs_new_protected:Npn  \@@_backend_attach_tree_name:nN #1 #2 %#1 object ref , #2 in case the name must be retourned
+   {
+     \int_gincr:N \g_@@_file_tree_name_int
+     \tl_set:Nx #2 { \@@_file_tree_name: }
+     \seq_gput_right:Nx \g_@@_file_tree_name_seq { #2 ~#1 }
+   }
+ }
+
+% dvips
+\bool_if:nT {\sys_if_engine_pdftex_p: && !\sys_if_output_pdf_p:}
   {
-    \file_get_full_name:nN {#1} \l_pdffile_full_name_str
-    \pdf_object_now:nx {dict}
+    % https://github.com/latex3/latex3/issues/710
+    \cs_if_free:NT \__pdf_backend_object_write_fstream:nn
       {
-        \pdfdict_map:n {file/FileSpec}
-        /EF <</F~#2/UF~#2>>
+        \cs_new_protected:Npn \__pdf_backend_object_write_fstream:nn #1#2
+          {
+            \exp_args:Nx
+              \__pdf_backend_object_write_fstream:nnn {#1} #2
+          }
+
+        \cs_new_protected:Npn \__pdf_backend_object_write_fstream:nnn #1#2#3
+          {
+            \__kernel_backend_literal:n
+              { ps::[nobreak]~
+                SDict ~ begin ~
+                mark ~ #1 ~ << #2 >> /PUT ~ pdfmark ~
+                mark ~ #1 ~ ( #3 )~ (r)~ file ~ /PUT ~ pdfmark ~
+                end
+              }
+          }
+       }
+     % https://github.com/latex3/latex3/issues/709
+     \cs_set_protected:Npn \__pdf_backend_object_write_stream:nnn #1#2#3
+        {
+         \__kernel_backend_literal:n
+           {
+            ps::[nobreak]~
+             SDict ~ begin ~
+              mark ~ #1 ~ ( #3 ) /PUT ~ pdfmark ~
+              mark ~ #1 ~ << #2 >> /PUT ~ pdfmark ~
+              end
+           }
+        }
+
+    \cs_new_protected:Npn  \@@_backend_attach_tree_name:nN #1 #2
+      {
+        \int_gincr:N \g_@@_file_tree_name_int
+        \tl_set:Nx #2 { \@@_file_tree_name: }
+        \@@_backend_pdfmark:x
+          {
+            /Name~#2~
+            /FS~#1~
+            /EMBED
+          }
       }
-    \tl_set:Nx #3 {\pdf_object_last:}
-    \int_gincr:N \g_@@_file_embedname_int
-    \seq_gput_right:Nx \g_@@_file_embednames_seq { \@@_file_embedname:~\pdf_object_last: }
   }
+
+%    \end{macrocode}
+% \begin{function}[added = 2020-04-24]
+%   {\pdffile_attach:n, \pdffile_attach:nN,}
+%   \begin{syntax}
+%     \cs{pdffile_attach:n}  \Arg{name} \\
+%     \cs{pdffile_attach:nN}  \Arg{name} \meta{tl var}
+%   \end{syntax}
+%   This attaches the file with name \Arg{name} which has been embedded
+%   with \csname{pdffile_embed:nn}\Arg{name}\Arg{file} to the attachments panel
+%   of the pdf reader. \meta{tl var} stores the name used in the name tree, in
+%   case it is needed to setup up for example a collection.
+%\end{function}
+%    \begin{macrocode}
+
+\cs_new_protected:Npn \pdffile_attach:nN #1 #2 % name of filespec object, #2 in case the name must be retourned
+ {
+   \@@_backend_object_if_exist:nTF { #1}
+     {
+       \exp_args:Nx
+       \@@_backend_attach_tree_name:nN {\pdf_object_ref:n{#1}} #2
+     }
+     {
+       \msg_error:nnn { pdffile } { file-object-no-found } { #1 }
+     }
+ }
+
+\cs_new_protected:Npn \pdffile_attach:n #1 % name of filespec object
+ {
+   \@@_backend_object_if_exist:nTF { #1}
+     {
+       \exp_args:Nx
+         \@@_backend_attach_tree_name:nN
+           {\pdf_object_ref:n{#1}} \l_@@_file_tmpa_tl
+     }
+     {
+       \msg_error:nnn { pdffile } { file-object-no-found } { #1 }
+     }
+ }
+
+%for anonymous objects. This allows to use the interface with objects not
+% created with l3 commands / naming
+\cs_new_protected:Npn \pdffile_attach_last:N #1 % #1 in case the name must be retourned
+ {
+   \tl_set:Nx \l_@@_file_tmpa_tl {\pdf_object_last:}
+   \exp_args:Nx
+     \@@_backend_attach_tree_name:nN { \l_@@_file_tmpa_tl } #1
+ }
+
+\cs_new_protected:Npn \pdffile_attach_last:
+ {
+   \tl_set:Nx \l_@@_file_tmpa_tl {\pdf_object_last:}
+   \exp_args:Nx
+     \@@_backend_attach_tree_name:nN { \l_@@_file_tmpa_tl } \l_@@_file_tmpa_tl
+ }
+
+
 %    \end{macrocode}
 % \end{macro}
 %    \begin{macrocode}
diff --git a/pdfresources.dtx b/pdfresources.dtx
index 0b720e4..1d1cd07 100644
--- a/pdfresources.dtx
+++ b/pdfresources.dtx
@@ -367,40 +367,43 @@
 % \end{function}
 % \begin{macro}{ \@@_backend_pageobject_ref:n }
 %    \begin{macrocode}
-%pdftex
-\bool_if:nT {\sys_if_engine_pdftex_p: && \sys_if_output_pdf_p:}
-  {
-    \cs_new:Npn \@@_backend_pageobject_ref:n #1
-      {
-        \tex_pdfpageref:D #1 ~ \c_space_tl 0 ~ R
-      }
-  }
-%luatex
-\sys_if_engine_luatex:T
+% command is in git.
+\cs_if_free:NT \@@_backend_pageobject_ref:n
   {
-    \cs_new:Npn \@@_backend_pageobject_ref:n #1
-      {
-        \tex_pdffeedback:D~pageref #1 ~ \c_space_tl 0 ~ R
-      }
-  }
-%dvips
-\bool_if:nT {\sys_if_engine_pdftex_p: && !\sys_if_output_pdf_p: }
-  {
-    \cs_new:Npn \@@_backend_pageobject_ref:n #1
-      {
-        {Page#1}
-      }
-  }
+  %pdftex
+  \bool_if:nT {\sys_if_engine_pdftex_p: && \sys_if_output_pdf_p:}
+    {
+      \cs_new:Npn \@@_backend_pageobject_ref:n #1
+        {
+          \tex_pdfpageref:D #1 ~ \c_space_tl 0 ~ R
+        }
+    }
+  %luatex
+  \sys_if_engine_luatex:T
+    {
+      \cs_new:Npn \@@_backend_pageobject_ref:n #1
+        {
+          \tex_pdffeedback:D~pageref #1 ~ \c_space_tl 0 ~ R
+        }
+    }
+  %dvips
+  \bool_if:nT {\sys_if_engine_pdftex_p: && !\sys_if_output_pdf_p: }
+    {
+      \cs_new:Npn \@@_backend_pageobject_ref:n #1
+        {
+          {Page#1}
+        }
+    }
 
-%xetex
-\sys_if_engine_xetex:T
-  {
-    \cs_new:Npn \@@_backend_pageobject_ref:n #1
-      {
-        @page#1
-      }
+  %xetex
+  \sys_if_engine_xetex:T
+    {
+      \cs_new:Npn \@@_backend_pageobject_ref:n #1
+        {
+          @page#1
+        }
+    }
   }
-
 \cs_new:Npn \pdf_pageobject_ref:n #1 { \@@_backend_pageobject_ref:n { #1 }}
 
 %% no idea here, so ...
@@ -1719,7 +1722,46 @@
 % the backend command is already in the driver:
 % \cs{@@_backend_catalog_gput:nn}
 %
-%
+% \paragraph { Special case: the /Names dictionary }
+% Entries to /Names are handled differently, in part (/Desc) it is automatic, for
+% other special commands like \cs{pdfnames} must be used.
+%    \begin{macrocode}
+% pdflatex
+\bool_if:nT {\sys_if_engine_pdftex_p: && \sys_if_output_pdf_p:}
+ {
+   \cs_new_protected:Npn \@@_backend_NamesEmbeddedFiles_gpush:n #1 %array content
+     {
+        \pdf_object_now:nn {dict} {/Names [#1] }
+        \pdfnames{/EmbeddedFiles~\pdf_object_last:}
+     }
+ }
+
+\sys_if_engine_luatex:T
+ {
+   \cs_new_protected:Npn \@@_backend_NamesEmbeddedFiles_gpush:n #1 %array content
+     {
+       \pdf_object_now:nn {dict} {/Names [#1] }
+       \pdfextension~names~{/EmbeddedFiles~\pdf_object_last: }
+     }
+ }
+
+\sys_if_engine_xetex:T
+ {
+   \cs_new_protected:Npn \@@_backend_NamesEmbeddedFiles_gpush:n #1 %array content
+     {
+       \pdf_object_now:nn {dict} { /Names [#1] }
+       %n or x?
+       \__pdf_backend:x {put~@names~<</EmbeddedFiles~\pdf_object_last: >>}
+     }
+ }
+
+%dvips: noop
+\bool_if:nT {\sys_if_engine_pdftex_p: && !\sys_if_output_pdf_p:}
+  {
+    \cs_new_protected:Npn \@@_backend_NamesEmbeddedFiles_gpush:n #1 {}
+  }
+
+%    \end{macrocode}
 % \subsubsection{\enquote{Catalog} \& subdirectories / management }
 % \begin{NOTE}{UF}
 % The catalog dictionary is filled by e.g. \cs{pdfcatalog}. Multiple appearances of
@@ -1755,6 +1797,13 @@
 % but in some subsubdictionary or are actually part of an array.
 % To handle this some pathes use internally special handlers.
 %
+% \potentialclash In some cases entries are added implicitly.
+% For example entries to the name
+% tree of the \texttt{/EmbeddedFiles} key in the \texttt{/Names} directory are
+% added with the commands of the \texttt{l3pdffile} module. This clashes with
+% e.g. the embedfile package which should not be used!
+%
+%
 %   \paragraph{Entries at the top level of the catalog}
 %   The Names in the following tabular are entries that are added to the
 %   top level of the catalog.
@@ -1955,7 +2004,6 @@
   }
 %    \end{macrocode}
 % \end{macro}
-%
 % \paragraph {Building the catalog: Push order}
 % \begin{macro}{\@@_dict_Catalog_gpush:}
 %    \begin{macrocode}
@@ -1971,6 +2019,8 @@
     \use:c { @@_dict_/Catalog/ViewerPreferences_gpush: }
     % output the single values:
     \prop_map_function:cN { \@@_dict_gname:n {Catalog} }  \@@_backend_catalog_gput:nn
+    % output names tree:
+    \use:c { @@_dict_/Catalog/Names/EmbeddedFiles_gpush: }
   }
 %    \end{macrocode}
 % \end{macro}
@@ -2246,6 +2296,22 @@
   }
 %    \end{macrocode}
 % \end{macro}
+% \paragraph{Building catalog entries: Names/EmbeddedFiles}
+% The entry should only be added if there are actually embedded files.
+% This can be tested by checking the names_seq
+% \begin{macro}{\@@_dict_/Catalog/Names/EmbeddedFiles_gpush:}
+%    \begin{macrocode}
+\seq_new:N \g_@@_file_tree_name_seq
+\cs_new_protected:cpn { @@_dict_/Catalog/Names/EmbeddedFiles_gpush: }
+  {
+    \seq_if_empty:NF \g_@@_file_tree_name_seq
+      {
+        \exp_args:Nx \@@_backend_NamesEmbeddedFiles_gpush:n
+          {
+            \seq_use:Nn \g_@@_file_tree_name_seq {~}
+          }
+      }
+  }
 %
 % \subsection{Local dictonaries}
 %





More information about the latex3-commits mailing list.