[latex3-commits] [git/LaTeX3-latex3-pdfresources] renamedict77: more embedded files (ffb2d3d)
Ulrike Fischer
fischer at troubleshooting-tex.de
Thu Apr 23 00:38:59 CEST 2020
Repository : https://github.com/latex3/pdfresources
On branch : renamedict77
Link : https://github.com/latex3/pdfresources/commit/ffb2d3d3945a041f287d47e9a759ff86cd131866
>---------------------------------------------------------------
commit ffb2d3d3945a041f287d47e9a759ff86cd131866
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date: Thu Apr 23 00:38:59 2020 +0200
more embedded files
>---------------------------------------------------------------
ffb2d3d3945a041f287d47e9a759ff86cd131866
experiments/embedfiles.tex | 60 ++++++++++++++++++++++++----------------
l3pdffile.dtx | 68 ++++++++++++++++++++++++++++++++++++++++++++--
pdfresources.dtx | 6 ++--
3 files changed, 103 insertions(+), 31 deletions(-)
diff --git a/experiments/embedfiles.tex b/experiments/embedfiles.tex
index 726eb3f..175339d 100644
--- a/experiments/embedfiles.tex
+++ b/experiments/embedfiles.tex
@@ -10,39 +10,51 @@
\section{a}
blub
\ExplSyntaxOn
-\pdfdict_put:nnn {embeddedfile}{Subtype}{\pdftool_name:n{application/postscript}}
-\pdffile_embed:nN {example-image.eps}\l_tmpa_tl
-\pdfdict_put:nnn {embeddedfile}{Subtype}{\pdftool_name:n{text/plain}}
-\pdffile_embed:nN {testinput.txt}\l_tmpa_tl
+\tl_new:N\l_file_a_tl
+\tl_new:N\l_file_b_tl
+\pdfdict_put:nnn {embeddedfile}{Subtype}{\pdftool_name:n{application/postscript}}
+\pdfdict_put:nnn {embeddedfile/FileSpec} {AFRelationship}{/Source}
+\pdfdict_put:nnn {embeddedfile/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
+
+\pdfdict_put:nnn {embeddedfile}{Subtype}{\pdftool_name:n{text/plain}}
+\pdfdict_put:nnn {embeddedfile/FileSpec} {AFRelationship}{/Data}
+\pdfdict_put:nnn {embeddedfile/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
-\pdf_object_new:nn {myfilespec}{dict}
-\pdf_object_write:nx {myfilespec}
- {
- /Type /Filespec
- /F (example-image.eps)
- /UF (example-image.eps)
- /AFRelationship /Source
- /EF <</F~\l_tmpa_tl >>
- /Desc (this~is~a~description)
- }
-\pdf_object_new:nn {myfilespec2}{dict}
-\pdf_object_write:nx {myfilespec2}
- {
- /Type /Filespec
- /F (ftestinput.txt)
- /UF (blubltestinput.txt)
- /AFRelationship /Source
- /EF <</F~\l_tmpa_tl >>
- }
+%\pdf_object_new:nn {myfilespec}{dict}
+%\pdf_object_write:nx {myfilespec}
+% {
+% /Type /Filespec
+% /F (example-image.eps)
+% /UF (example-image.eps)
+% /AFRelationship /Source
+% /EF <</F~\l_tmpa_tl >>
+% /Desc (this~is~a~description)
+% }
+%
+%\pdf_object_new:nn {myfilespec2}{dict}
+%\pdf_object_write:nx {myfilespec2}
+% {
+% /Type /Filespec
+% /F (ftestinput.txt)
+% /UF (blubltestinput.txt)
+% /AFRelationship /Source
+% /EF <</F~\l_tmpa_tl >>
+% }
+%
\pdf_object_new:nn {embedfilelist}{dict}
\pdf_object_write:nx {embedfilelist}
{
- /Names[ (emded1)~\pdf_object_ref:n{myfilespec}~(xxx1)~\pdf_object_ref:n{myfilespec2}]
+ /Names[ \seq_use:Nn \g__pdf_file_embednames_seq {~}]
}
\bool_if:nT {\sys_if_engine_pdftex_p: && \sys_if_output_pdf_p:}
diff --git a/l3pdffile.dtx b/l3pdffile.dtx
index 7dff2e2..307cd07 100644
--- a/l3pdffile.dtx
+++ b/l3pdffile.dtx
@@ -229,8 +229,10 @@
% \begin{macrocode}
\tl_new:N \l_pdffile_embed_filename_tl
-\pdfdict_new:n {embeddedfile}
-\pdfdict_new:n {embeddedfile/Params}
+\pdfdict_new:n {embeddedfile}
+\pdfdict_put:nnn {embeddedfile}{Type}{/EmbeddedFile}
+\pdfdict_new:n {embeddedfile/Params}
+\pdfdict_new:n {embeddedfile/FileSpec}
\pdfdict_put:nnn {embeddedfile/Params}
{ModDate} { (\file_timestamp:n { \l_pdffile_embed_filename_tl }) }
@@ -238,9 +240,24 @@
{Size} { \file_size:n { \l_pdffile_embed_filename_tl } }
\pdfdict_put:nnn {embeddedfile/Params}
{CheckSum} { (\file_mdfive_hash:n { \l_pdffile_embed_filename_tl }) }
+
+
+\pdfdict_put:nnn {embeddedfile/FileSpec}
+ {Type} { /FileSpec }
+
+%escaping??
+\pdfdict_put:nnn {embeddedfile/FileSpec}
+ {F} { (\l_pdffile_embed_filename_tl) }
+
+\pdfdict_put:nnn {embeddedfile/FileSpec}
+ {UF} { (\l_pdffile_embed_filename_tl) }
+
+\pdfdict_put:nnn {embeddedfile/FileSpec}
+ {AFRelationship} { /Unspecified }
+
% \end{macrocode}
% \end{variable}
-%
+% these macros must be combined ...
% \begin{macro}{\pdffile_embed:nN}
% \begin{macrocode}
\cs_new_protected:Npn \pdffile_embed:nN #1 #2
@@ -265,7 +282,52 @@
% \end{macrocode}
% \end{macro}
%
+% \begin{macro}{\pdffile_spec:nN}
+% \begin{macrocode}
+\cs_new_protected:Npn \pdffile_spec:nN #1 #2
+ {
+ \tl_set:Nn \l_pdffile_embed_filename_tl {#1}
+ \pdf_object_now:nx {dict}
+ {
+ \pdfdict_map:n {embeddedfile/FileSpec}
+ }
+ \tl_set:Nx #2 {\pdf_object_last:}
+ }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}{\pdffile_embed_spec:nnN}
+% \begin{macrocode}
+\int_new:N \g_@@_file_embedname_int
+\seq_new:N \g_@@_file_embednames_seq
+\cs_new:Npn \@@_file_embedname:
+ {
+ (
+ l3ef
+ \int_compare:nNnT {\g_@@_file_embedname_int} < {10}
+ {0}
+ \int_compare:nNnT {\g_@@_file_embedname_int} < {100}
+ {0}
+ \int_compare:nNnT {\g_@@_file_embedname_int} < {1000}
+ {0}
+ \int_use:N \g_@@_file_embedname_int
+ )
+ }
+\cs_new_protected:Npn \pdffile_embed_spec:nnN #1 #2 #3 %#1 file name, #2 stream ref, #3tlvar
+ {
+ \tl_set:Nn \l_pdffile_embed_filename_tl {#1}
+ \pdf_object_now:nx {dict}
+ {
+ \pdfdict_map:n {embeddedfile/FileSpec}
+ /EF <</F~#2/UF~#2>>
+ }
+ \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}
+% \end{macro}
% \begin{macrocode}
%</package>
% \end{macrocode}
diff --git a/pdfresources.dtx b/pdfresources.dtx
index 7b633c6..0b720e4 100644
--- a/pdfresources.dtx
+++ b/pdfresources.dtx
@@ -1715,10 +1715,6 @@
% \end{macrocode}
%
% \subsection{\enquote{Catalog} \& subdirectories (pdfcatalog) }
-% \begin{NOTE}{UF}
-% missing is an access to /Names (\pdfnames), needed for EmbeddedFiles
-% missing is a handler for Collection (ditto embedfiles)
-% \end{NOTE}
% \subsubsection{\enquote{Catalog} \& subdirectories / backend}
% the backend command is already in the driver:
% \cs{@@_backend_catalog_gput:nn}
@@ -1743,6 +1739,8 @@
% /DSS (dict, pdf 2.0)
% /Acroform/DR/ExtGState etc probably unneeded.
% /Collection is currently missing, need to understand embedfile first.
+% missing is an access to /Names (\pdfnames), needed for EmbeddedFiles
+% (implicitly done, no direct access needed)
% \end{NOTE}
% The catalog is a central dictionary in a PDF with a number of subdictionaries.
% Entries to the top level of the catalog can be added with
More information about the latex3-commits
mailing list.