[latex3-commits] [git/LaTeX3-latex3-pdfresources] renamedict77: more embedding files (19ef58c)

Ulrike Fischer fischer at troubleshooting-tex.de
Wed Apr 22 19:14:53 CEST 2020


Repository : https://github.com/latex3/pdfresources
On branch  : renamedict77
Link       : https://github.com/latex3/pdfresources/commit/19ef58c9b77c007f1aececf8a8d58c1738229ee3

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

commit 19ef58c9b77c007f1aececf8a8d58c1738229ee3
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date:   Wed Apr 22 19:14:53 2020 +0200

    more embedding files


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

19ef58c9b77c007f1aececf8a8d58c1738229ee3
 experiments/embedfiles.tex | 83 ++++++++++++++++++++++++++++++++++++++++++++++
 experiments/testinput.txt  |  1 +
 l3pdffile.dtx              | 63 ++++++++++++++++++++++++++---------
 3 files changed, 132 insertions(+), 15 deletions(-)

diff --git a/experiments/embedfiles.tex b/experiments/embedfiles.tex
index 1697dc1..726eb3f 100644
--- a/experiments/embedfiles.tex
+++ b/experiments/embedfiles.tex
@@ -1,12 +1,95 @@
+% !Mode:: "TeX:UTF-8:Main"
 \documentclass{article}
 \usepackage{pdfresources,l3pdffile}
+\usepackage{hyperref}
 \ExplSyntaxOn
 \pdf_uncompress:
 \ExplSyntaxOff
 \begin{document}
+\subsection{n}
+\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
+
+
+\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}]
+ }
+
+\bool_if:nT {\sys_if_engine_pdftex_p: && \sys_if_output_pdf_p:}
+ {
+  \pdfnames{/EmbeddedFiles~\pdf_object_ref:n{embedfilelist} }
+ }
+
+\sys_if_engine_luatex:T
+ {
+   \pdfextension names {/EmbeddedFiles~\pdf_object_ref:n{embedfilelist} }
+ }
+
+\sys_if_engine_xetex:T
+ {
+  \special{pdf: put @names <</EmbeddedFiles~\pdf_object_ref:n{embedfilelist}>>}
+ }
+
+\bool_if:nT {\sys_if_engine_pdftex_p: && !\sys_if_output_pdf_p:}
+ {
+  %\pdfnames{/EmbeddedFiles~\pdf_object_ref:n{embedfilelist} }
+  %[/Name (Unicode Name)
+%/FS << /Type /Filespec /F (name) /EF << /F {streamName} >> >>
+%EMBED pdfmark
+   \__pdf_backend_pdfmark:x
+     {
+       /Name~ (e22)~
+       /FS~\pdf_object_ref:n{myfilespec}
+       ~ /EMBED
+   }
+   \__pdf_backend_pdfmark:x
+     {
+       /Name~ (e3)~
+       /FS~\pdf_object_ref:n{myfilespec2}
+       ~ /EMBED
+   }
+  }
+
+
+
 \ExplSyntaxOff
 \end{document}
+
+immediate\pdfobj{%
+          <<%
+            /Names[\EmFi at list]%
+          >>%
+        }%
+        \pdfnames{%
+          /EmbeddedFiles \the\pdflastobj\ltx at space 0 R%
+        }%
\ No newline at end of file
diff --git a/experiments/testinput.txt b/experiments/testinput.txt
new file mode 100644
index 0000000..8baef1b
--- /dev/null
+++ b/experiments/testinput.txt
@@ -0,0 +1 @@
+abc
diff --git a/l3pdffile.dtx b/l3pdffile.dtx
index 6a51b82..7dff2e2 100644
--- a/l3pdffile.dtx
+++ b/l3pdffile.dtx
@@ -69,6 +69,15 @@
 % \begin{enumerate}
 % \item Embed the file in a stream. (This is optional).
 % \item Create a FileSpec dictionary which if needed reference the embedded file.
+% \begin{verbatim}
+% <<
+% /Type /Filespec
+% /F (l3pdffile.dtx)
+% /UF (l3pdffile.dtx)
+% /AFRelationship /Source
+% /EF <</F 21 0 R>>   %case 3, embedded file
+% >>
+% \end{verbatim}
 % \item Reference the FileSpec dictionary so that the user can access the file.
 %       This can be done in various way:
 %       \begin{enumerate}
@@ -86,7 +95,7 @@
 %             \end{tabular}
 %
 %             The AP takes precedance over Border and similar keys.
-%       \item Through an entry in the EmbeddedFiles name tree. This what embedfiles does.
+%       \item Through an entry in the EmbeddedFiles name tree. This is what embedfiles does.
 %       \begin{verbatim}
 %       20 0 obj %Document Name tree
 %        <</EmbeddedFiles 21 0 R>>
@@ -95,26 +104,50 @@
 %        <</Names [(AcmeCustomCrypto Protected PDF.pdf) 17 0 R]>>
 %        endobj
 %       \end{verbatim}
-%       \item Through the /AF key in various objects (pdf 2.0), the value is normally an array of object
-%       references.
-%        But it can also be a name which is mapped to an array in /Properties:
+%       The strings (keys) in the /Names dictionary must be sorted lexically. But they
+%       don't have to be the file name or anything related to the file name. So the code will
+%       use l3emb0001, l3emb0002. The key is needed only in one place:
+%       to identify the start file in a collection.
+%
+%       \item Through the /AF key in various objects (pdf 2.0). The value is normally an array of object
+%       references, but it can also be a name which is mapped to an array in /Properties:
 %        \begin{verbatim}
 %        /AF /NamedAF BDC
 %        /Properties <</NamedAF [12 0 R]
 %        \end{verbatim}
-%        The related FileSpec dictionary should contain an /AFRelationship key in this case.
-%       \end{enumerate}
+%        The related FileSpec dictionary should contain an /AFRelationship key in this case:
+%
+%       \begin{tabular}{lp{6cm}}
+%       Source  & shall be used if this file specification is the original
+%                source material for the associated content.\\
+%       Data    & shall be used if this file specification represents information used to
+%                derive a visual presentation – such as for a table or a graph.\\
+%       Alternative & shall be used if this file specification is an
+%               alternative representation of content, for example audio.\\
+%       Supplement & shall be used if this file specification represents
+%       a supplemental representation of the original source or data
+%       that may be more easily consumable
+%       (e.g., A MathML version of an equation).\\
+%       EncryptedPayload & shall be used if this file specification
+%       is an encrypted payload document that should be displayed to the user
+%       if the PDF processor has the cryptographic filter
+%       needed to decrypt the document.\\
+%       FormData & shall be used if this file specification
+%       is the data associated with the AcroForm
+%       (see 12.7.3, "Interactive form dictionary") of this PDF.\\
+%       Schema & shall be used if this file specification is a schema
+%       definition for the associated object
+%       (e.g. an XML schema associated with a metadata stream).\\
+%       Unspecified &(default value) shall be used when the
+%       relationship is not known
+%       or cannot be described using one of the other values.\\
+%       Other names & Second-class names (see Annex E,
+%       “(normative) PDF Name Registry") should be used to
+%       represent other types of relationships.
+%       \end{tabular}
+%      \end{enumerate}
 % \end{enumerate}
 %
-% \begin{verbatim}
-% <<
-% /Type /Filespec
-% /F (l3pdffile.dtx)
-% /UF (l3pdffile.dtx)
-% /AFRelationship /Source
-% /EF <</F 21 0 R>>   %case 3, embedded file
-% >>
-% \end{verbatim}
 %
 %\subsection{Embedding a file}
 % Embedding an existing file is in most cases quite straightforward. It can be done with





More information about the latex3-commits mailing list.