[latex3-commits] [git/LaTeX3-latex3-pdfresources] splitting: error corrections (6935a77)

Ulrike Fischer fischer at troubleshooting-tex.de
Wed Jul 1 18:24:49 CEST 2020


Repository : https://github.com/latex3/pdfresources
On branch  : splitting
Link       : https://github.com/latex3/pdfresources/commit/6935a77db291fd27e8cc0c314ef0a1507efd839a

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

commit 6935a77db291fd27e8cc0c314ef0a1507efd839a
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date:   Wed Jul 1 18:24:49 2020 +0200

    error corrections


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

6935a77db291fd27e8cc0c314ef0a1507efd839a
 experiments/embedfiles.tex |  11 +++--
 l3pdffile.dtx              | 101 +++++++++++++++++++++++++--------------------
 2 files changed, 64 insertions(+), 48 deletions(-)

diff --git a/experiments/embedfiles.tex b/experiments/embedfiles.tex
index 914b431..ef38735 100644
--- a/experiments/embedfiles.tex
+++ b/experiments/embedfiles.tex
@@ -26,10 +26,15 @@
 \group_begin:
 \pdfdict_put:nnn  {file/FileSpec} {AFRelationship}{/Source}
 \pdfdict_put:nnn  {file/FileSpec} {Desc}{(this~is~a~eps)}
+
 \pdffile_embed_file:nnn {testinput.txt}{grüße.tex}{example1}
 
-\prop_show:N \g__pdf_file_embed_sources_prop
-\pdffile_attach:n {example1}
+\pdfdict_put:nnn  {file/FileSpec} {AFRelationship}{/Data}
+\pdfdict_put:nnn  {file/FileSpec} {Desc}{(this~is~a~text~file)}
+\pdffile_embed_stream:nnn {testinput.txt} {stream.txt} {example2}
+
+\prop_show:N \g__pdffile_file_embed_sources_prop
+%\pdffile_attach:n {example1}
 \group_end:
 \end{document}
 %
@@ -37,7 +42,7 @@
 \pdfdict_put:nnn  {file/FileSpec} {AFRelationship}{/Data}
 \pdfdict_put:nnn  {file/FileSpec} {Desc}{(this~is~a~text~file)}
 \pdffile_embed_file:nnn {testinput.txt} {} {example2}
-\pdffile_attach:n {example2}
+%\pdffile_attach:n {example2}
 \group_end:
 
 \group_begin:
diff --git a/l3pdffile.dtx b/l3pdffile.dtx
index 823a603..c40c366 100644
--- a/l3pdffile.dtx
+++ b/l3pdffile.dtx
@@ -350,7 +350,7 @@
   {Size}     { \file_size:n { \l_pdffile_source_full_name_str } }
 \pdfdict_put:nnn { file/Params }
   {CheckSum} { (\file_mdfive_hash:n { \l_pdffile_source_full_name_str }) }
-
+\pdfdict_new:n   { file/streamParams }
 \pdfdict_new:n   { file/FileSpec }
 \pdfdict_put:nnn { file/FileSpec }
   {Type} { /FileSpec }
@@ -388,11 +388,10 @@
 
 \cs_generate_variant:Nn \@@_file_mimetype_set:nN {VN}
 
+%#1 file name,
+%#2 tl, should be empty or contain /Subtype /mimtype
+  %   e.g. result from \@@_file_mimetype_set:NN
 \cs_new_protected:Npn \@@_file_fstream_write:nN #1 #2
-                                   %#1 file name,
-                                   %#2 tl, should be empty or contain /Subtype /mimtype
-                                   %   e.g. result from \@@_file_mimetype_set:NN
-
   {
     \pdf_object_now:nx { fstream }
       {
@@ -414,9 +413,35 @@
 
 \cs_generate_variant:Nn \@@_file_fstream_write:nN {VN}
 
-\cs_new_protected:Npn \@@_file_filespec_write:nnn #1 #2 #3 %#1 name of dict object,
-                                                           %#2 target file name,
-                                                           %#3 object ref
+%#1 file content
+%#2 tl, should be empty or contain /Subtype /mimtype
+    %e.g. result from \@@_file_mimetype_set:NN
+\cs_new_protected:Npn \@@_file_stream_write:nN #1 #2
+  {
+    \pdf_object_now:nx { stream }
+      {
+        {
+          #2
+          \pdfdict_map:n {file}
+          \pdfdict_if_empty:nF {file/streamParams}
+            {
+              /Params
+                <<
+                  \pdfdict_map:n {file/streamParams}
+                >>
+            }
+        }
+        { \exp_not:n { #1 } }
+      }
+     \tl_clear:N \l_@@_file_automimetype_tl
+   }
+
+\cs_generate_variant:Nn \@@_file_stream_write:nN {VN}
+
+%#1 symbolic name of dict object -- a prefix is added to have some namespace,
+%#2 target file name,
+%#3 object ref of the file stream.
+\cs_new_protected:Npn \@@_file_filespec_write:nnn #1 #2 #3
   {
     \tl_if_blank:nT { #2 }
       {
@@ -443,11 +468,13 @@
 %% separate file name to embed and file name to display!
 % we record here the source file. This allows also to test if an object name
 % has an embedded file or is only a filespec
-%
+
 \prop_new:N \g_@@_file_embed_sources_prop
 
+%#1 {source filename}
+%#2 {target filename}
+%#3 { filespec object name } (will internally get a prefix!)
 \cs_new_protected:Npn \pdffile_embed_file:nnn #1 #2 #3
-   %\Arg{source filename} \Arg{target filename} \Arg{ file object name }
   { %               if #1 empty => only filespec
     %               if #2 empty => = #1
     \pdf_object_if_exist:nTF { @@_#3 }
@@ -500,49 +527,33 @@
   }
 
 
+%#1{stream content}
+%#2{target filename}
+%#3{file object name }
 \cs_new_protected:Npn \pdffile_embed_stream:nnn #1 #2 #3
-   %\Arg{source filename} \Arg{target filename} \Arg{ file object name }
-  { %               if #1 empty => only filespec
-    %               if #2 empty => = #1
+  {
+    %               if #2 empty => error
     \pdf_object_if_exist:nTF { @@_#3 }
       {
-        \msg_error:nnn { pdffile }{ object-exists } { #3 }
+         \msg_error:nnn { pdffile }{ object-exists } { #3 }
       }
       {
-        \tl_if_blank:nTF { #1 }
+        \tl_if_blank:nTF {#2}
           {
-            \tl_set:Nn \l_@@_file_embed_ref_tl {}
-          }
-          {
-            \file_get_full_name:nNTF {#1} \l_pdffile_source_full_name_str
-              {
-                \prop_gput:NnV
-                  \g_@@_file_embed_sources_prop
-                  { #3 }
-                  \l_pdffile_source_full_name_str
-                \@@_file_mimetype_set:NN
-                  \l_pdffile_source_full_name_str
-                  \l_@@_file_automimetype_tl
-                \@@_file_fstream_write:NN
-                  \l_pdffile_source_full_name_str
-                  \l_@@_file_automimetype_tl
-                \tl_set:Nx \l_@@_file_embed_ref_tl { \pdf_object_last: }
-              }
-              {
-                \msg_error:nnn { pdffile }{ file-not-found }{ #1 }
-              }
-
-           }
-        \tl_if_blank:nTF { #2 }
-          {
-            \exp_args:Nnnx
-              \@@_file_filespec_write:nnn
-                %#1 dict, #2 target file name, #3 object ref
-                { @@_#3 }
-                { #1 }
-                {\l_@@_file_embed_ref_tl}
+            %error or use #3 instead??
           }
           {
+            \prop_gput:NnV
+               \g_@@_file_embed_sources_prop
+               { #3 }
+               {(stream)~#2}
+            \@@_file_mimetype_set:nN
+              { #2 }
+              \l_@@_file_automimetype_tl
+            \@@_file_stream_write:nN
+              { #1 }
+              \l_@@_file_automimetype_tl
+            \tl_set:Nx \l_@@_file_embed_ref_tl { \pdf_object_last: }
             \exp_args:Nnnx
               \@@_file_filespec_write:nnn
                 %#1 dict, #2 target file name, #3 object ref





More information about the latex3-commits mailing list.