[latex3-commits] [git/LaTeX3-latex3-pdfresources] testanonstream: anonym streams (93981cc)

Ulrike Fischer fischer at troubleshooting-tex.de
Mon Feb 13 20:41:23 CET 2023


Repository : https://github.com/latex3/pdfresources
On branch  : testanonstream
Link       : https://github.com/latex3/pdfresources/commit/93981cc6af598abc91534a95c241325d23b82ac1

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

commit 93981cc6af598abc91534a95c241325d23b82ac1
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date:   Mon Feb 13 20:41:23 2023 +0100

    anonym streams


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

93981cc6af598abc91534a95c241325d23b82ac1
 l3pdffile.dtx | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 56 insertions(+), 5 deletions(-)

diff --git a/l3pdffile.dtx b/l3pdffile.dtx
index 835a6cf..0807a09 100644
--- a/l3pdffile.dtx
+++ b/l3pdffile.dtx
@@ -296,12 +296,14 @@
 %  https://chat.stackexchange.com/transcript/message/54181193#54181193
 % \end{NOTE}
 %
-% \begin{function}{\pdffile_embed_stream:nnn}
+% \begin{function}{\pdffile_embed_stream:nnn,\pdffile_embed_stream:nnN}
 %   \begin{syntax}
-%     \cs{pdffile_embed_stream:nnn} \Arg{content} \Arg{target filename} \Arg{object name }
+%     \cs{pdffile_embed_stream:nnn} \Arg{content} \Arg{target filename} \Arg{object name}\\
+%     \cs{pdffile_embed_stream:nnN} \Arg{content} \Arg{target filename} \Arg{tl var}
 %   \end{syntax}
 %   This commands embeds the \meta{content} in the PDF in a stream objects and
-%   creates a |/Filespec| dictionary object named \meta{object name}.
+%   creates either a |/Filespec| dictionary object named \meta{object name}, or stores
+%   the object reference (what you would get with \cs{pdf_object_ref:n}) in \meta{tl var}.
 %   \meta{content} is wrapped in a \cs{exp_not:n}.
 %   The object name must be unique. The command uses the content of the local
 %   dictionaries |l_pdffile|, |l_pdffile/streamParams| and |l_pdffile/Filespec|
@@ -440,6 +442,7 @@
 %   {
 %     \l_@@_tmpa_tl,
 %     \l_@@_tmpb_tl,
+%     \g_@@_tmpa_tl,
 %     \l_@@_tmpa_str,
 %     \l_@@_tmpb_str,
 %     \l_@@_ext_str,
@@ -451,6 +454,7 @@
 %    \begin{macrocode}
 \tl_new:N  \l_@@_tmpa_tl
 \tl_new:N  \l_@@_tmpb_tl
+\tl_new:N  \g_@@_tmpa_tl
 \str_new:N \l_@@_tmpa_str
 \str_new:N \l_@@_tmpb_str
 \str_new:N \l_@@_ext_str
@@ -543,7 +547,7 @@
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}{\pdffile_embed_file:nnn, \pdffile_embed_stream:nnn}
+% \begin{macro}{\pdffile_embed_file:nnn, \pdffile_embed_stream:nnn, \pdffile_embed_stream:nnN}
 % At first a command to set the mimetype. It either uses the current value
 % in the file dictionary, or tries to guess it from the extension.
 % \begin{macro}{\@@_mimetype_set:nN,\@@_mimetype_set:VN}
@@ -635,7 +639,7 @@
 %#3 object ref of the file stream.
 \cs_new_protected:Npn \@@_filespec_write:nnn #1 #2 #3
   {
-    \tl_if_blank:nT { #2 }
+    \tl_if_blank:nTF { #2 }
       {
         \msg_error:nn {pdffile}{target-name-missing}
       }
@@ -656,6 +660,32 @@
       }
   }
 
+%#1 target file name #2 object ref of file stream #3 reference of object
+\cs_new_protected:Npn \@@_filespec_write:nnN #1 #2 #3
+  {
+    \tl_if_blank:nTF { #1 }
+      {
+        \msg_error:nn {pdffile}{target-name-missing}
+      }
+      {
+        \group_begin:
+          \@@_filename_convert_to_print:nN  { #1 } \l_@@_tmpa_str
+          \pdfdict_put:nnx {l_pdffile/Filespec}{F} { \l_@@_tmpa_str }
+          \pdfdict_put:nnx {l_pdffile/Filespec}{UF}{ \l_@@_tmpa_str }
+          \pdf_object_unnamed_write:nx {dict}
+            {
+              \pdfdict_use:n { l_pdffile/Filespec}
+              \tl_if_empty:nF { #2 }
+                {
+                  /EF <</F~#2 /UF~#2>>
+                }
+            }
+        \tl_gset:Nx\g_@@_tmpa_tl{\pdf_object_ref_last:}    
+        \group_end:
+        \tl_set_eq:NN#3\g_@@_tmpa_tl
+      }
+  }
+
 \cs_set_eq:NN \pdffile_filespec:nnn \@@_filespec_write:nnn
 \cs_generate_variant:Nn \pdffile_filespec:nnn {nnx}
 %#1 {source filename}
@@ -756,6 +786,27 @@
      }
   }
 
+\cs_new_protected:Npn \pdffile_embed_stream:nnN #1 #2 #3
+  {
+     \tl_if_blank:nTF {#2}
+      { \@@_mimetype_set:nN {stream.txt}\l_@@_automimetype_tl}
+      { \@@_mimetype_set:nN { #2 } \l_@@_automimetype_tl }
+     \@@_stream_write:nN
+       { #1 }
+       \l_@@_automimetype_tl
+     \tl_set:Nx \l_@@_embed_ref_tl { \pdf_object_ref_last: }
+     \exp_args:Nxx
+       \@@_filespec_write:nnN
+         %#1 target file name, #2 object ref of stream, #3 object ref of filespec
+         { \tl_if_blank:nTF {#2}{stream.txt}{\exp_not:n{#2}} }
+         {\l_@@_embed_ref_tl}
+         #3
+     \prop_gput:Nxx
+        \g_pdffile_embed_prop
+        { #3 }
+        {{stream}{}{\tl_if_blank:nTF {#2}{stream.txt}{\exp_not:n{#2}}}}         
+  }
+  
 
 %    \end{macrocode}
 % \end{macro}





More information about the latex3-commits mailing list.