[latex3-commits] [git/LaTeX3-latex3-pdfresources] renamedict77: escaping files names (fb9a67a)

Ulrike Fischer fischer at troubleshooting-tex.de
Sat Apr 25 01:30:02 CEST 2020


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

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

commit fb9a67a949f922e812362ebaaee45954c0604123
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date:   Sat Apr 25 01:30:02 2020 +0200

    escaping files names


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

fb9a67a949f922e812362ebaaee45954c0604123
 experiments/embedfiles.tex                         | 170 +++------------------
 .../gr\303\274\303\237e hallo.txt"                 |   0
 .../gr\303\274\303\237e.txt"                       |   0
 l3pdffile.dtx                                      |   6 +-
 newpackages/new-pdfescape.sty                      |  16 +-
 pdfresources.dtx                                   |   6 +-
 6 files changed, 40 insertions(+), 158 deletions(-)

diff --git a/experiments/embedfiles.tex b/experiments/embedfiles.tex
index 7570686..1cc8b75 100644
--- a/experiments/embedfiles.tex
+++ b/experiments/embedfiles.tex
@@ -2,176 +2,44 @@
 \documentclass{article}
 \usepackage{pdfresources}
 \usepackage{l3pdffile}
-\usepackage{hyperref}
+\usepackage[customdriver=hgeneric-experimental]{hyperref}
 \ExplSyntaxOn
 \pdf_uncompress:
 \ExplSyntaxOff
+\usepackage{bookmark}
 \begin{document}
-\section{Testing embedding and attaching files}
+\section{grüße Testing embedding and attaching files}
 \ExplSyntaxOn
-\showoutput
-\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
-  {
-   \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>>
-%%      }
-%  }
-
+\group_begin:
 \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_embed:nn {example}{grüße.txt}
 \pdffile_attach:n {example}
+\group_end:
+\end{document}
+\group_begin:
+\pdfdict_put:nnn  {file/FileSpec} {AFRelationship}{/Source}
+\pdfdict_put:nnn  {file/FileSpec} {Desc}{(this~is~a~eps)}
+\pdffile_embed:nn {example}{example-image.eps}
+\pdffile_attach:n {example}
+\group_end:
 %
+\group_begin:
 \pdfdict_put:nnn  {file/FileSpec} {AFRelationship}{/Data}
 \pdfdict_put:nnn  {file/FileSpec} {Desc}{(this~is~a~text~file)}
+\pdfdict_put:nnn  {file/FileSpec} {F}{(Fnewname.txt)}
+\pdfdict_put:nnn  {file/FileSpec} {UF}{(UFnewname.txt)}
 \pdffile_embed:nn {test} {testinput.txt}
 \pdffile_attach:n {test}
+\group_end:
 %
+\group_begin:
 \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
+\group_end:
 
-%\tl_show:N\l_tmpa_tl
 \ExplSyntaxOff
 
 \end{document}
-%\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[ \seq_use:Nn \g__pdf_file_embednames_seq {~}]
- }
-
-\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/gr\303\274\303\237e hallo.txt"
similarity index 100%
copy from experiments/testinput.txt
copy to "experiments/gr\303\274\303\237e hallo.txt"
diff --git a/experiments/testinput.txt "b/experiments/gr\303\274\303\237e.txt"
similarity index 100%
copy from experiments/testinput.txt
copy to "experiments/gr\303\274\303\237e.txt"
diff --git a/l3pdffile.dtx b/l3pdffile.dtx
index 9f06cf9..a7c8f09 100644
--- a/l3pdffile.dtx
+++ b/l3pdffile.dtx
@@ -295,6 +295,7 @@
 % \end{variable}
 %    \begin{macrocode}
 \str_new:N  \l_pdffile_full_name_str
+\str_new:N  \l_pdffile_full_name_convert_str
 %    \end{macrocode}
 % Here we define and setup the local dictionaries
 %    \begin{macrocode}
@@ -314,9 +315,9 @@
   {Type} { /FileSpec }
 %escaping??
 \pdfdict_put:nnn {file/FileSpec}
-  {F} { (\l_pdffile_full_name_str) }
+  {F} { (\l_pdffile_full_name_convert_str) }
 \pdfdict_put:nnn {file/FileSpec}
-  {UF} { (\l_pdffile_full_name_str) }
+  {UF} { (\l_pdffile_full_name_convert_str) }
 \pdfdict_put:nnn {file/FileSpec}
   {AFRelationship} { /Unspecified }
 
@@ -369,6 +370,7 @@
       \tl_clear:N \l_@@_file_subtype_tl
       \tl_set:Nx  \l_@@_file_object_last_tl {\pdf_object_last:}
       \pdf_object_new:nn   { #1 } {dict}
+      \pdftool_str_convert:nN  { #2 } \l_pdffile_full_name_convert_str
       \pdf_object_write:nx { #1 }
         {
           \pdfdict_map:n {file/FileSpec}
diff --git a/newpackages/new-pdfescape.sty b/newpackages/new-pdfescape.sty
index b8500cd..3e5fc15 100644
--- a/newpackages/new-pdfescape.sty
+++ b/newpackages/new-pdfescape.sty
@@ -76,7 +76,21 @@
 
  \cs_generate_variant:Nn \str_escape_pdfname:n { e }
 
- \cs_set:Npn \pdftool_name:n #1
+ \cs_new:Npn \pdftool_name:n #1
     { / \str_escape_pdfname:e { \text_expand:n{#1} } }
 
 \cs_generate_variant:Nn \pdftool_name:n {V}
+
+\sys_if_engine_pdftex:TF
+  {
+    \cs_new:Npn \pdftool_str_convert:nN #1 #2
+      {
+         \str_set_convert:Nnnn #2 { #1 }{ utf8 } {utf16/string}
+      }
+  }
+  {
+    \cs_new:Npn \pdftool_str_convert:nN #1 #2
+      {
+        \str_set_convert:Nnnn #2 { #1 }{  } {utf16/string}
+      }
+  }
diff --git a/pdfresources.dtx b/pdfresources.dtx
index 1d1cd07..26e3514 100644
--- a/pdfresources.dtx
+++ b/pdfresources.dtx
@@ -1780,9 +1780,6 @@
 % /Dests ? difference to subdict in Names?
 % /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
@@ -1821,7 +1818,8 @@
 %   \noindent
 %   \begin{tabularx}{\linewidth}{ll>{\raggedright\arraybackslash}X}
 %    \bfseries Name           &  \bfseries Value  & \bfseries Remark \\\midrule
-%    Collection              &  objref or dict                        \\
+%    Collection              &  objref or dict     & the content should be
+%     build by external packages (see eg embedfile)                   \\
 %    DPartRoot               &  objref or dict     & PDF 2.0           \\
 %    Lang                    &  string             & e.g. \texttt{(de-DE)} \\
 %    Legal                   &  objref or dict                             \\





More information about the latex3-commits mailing list.