Please see the attached patch; it solves this issue and also a similar one with pdf.setnames() that I have reported before in [1], but which apparently has not been seen.

Warm regards,
Esger Renkema

[1] https://tug.org/pipermail/luatex/2021-June/007543.html

Aldus Esger Renkema, op vrijdag 25 februari 2022 om 17:40:
Dear list,

The two functions pdf.setxform[attributes|resources] mentioned in 14.1.4 of the manual appear to do nothing at all. The following file:

%% compile with plain luatex %%%%%%%%%%%%%%%%%%%%%%%%%%%
\pdfvariable compresslevel 0
\pdfvariable objcompresslevel 0
\pdfvariable xformresources {/Test1 /Value1}
\directlua {pdf.setxformresources('/Test2 /Value2')}
\setbox0=\hbox{Test}
\saveboxresource0
\useboxresource\lastsavedboxresourceindex
\bye
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

will result in the following pdf output:

1 0 obj
<< /Type /XObject /Subtype /Form /FormType 1 /BBox [ 0 0 18.597 6.808 ] /Matrix [ 1 0 
0 1 0 0 ] /Resources 7 0  R /Length 51 >>
stream
BT
/F1 9.96264 Tf
1 0 0 1 0 0 Tm [(T)83(est)]TJ
ET

endstream
endobj
7 0 obj
<< /Test1 /Value1 /Font << /F1 5 0 R >> /ProcSet [ /PDF /Text ] >>
endobj

where, as you see, the token list set throught \pdfvariable is written, but the string given to pdf.setxformresources ignored.

The same holds mutatis mutandis for pdf.xformattributes.

Warm regards,
Esger Renkema

diff --git a/source/texk/web2c/luatexdir/pdf/pdfdest.c b/source/texk/web2c/luatexdir/pdf/pdfdest.c
index ca3c76faa..b54951e9c 100644
--- a/source/texk/web2c/luatexdir/pdf/pdfdest.c
+++ b/source/texk/web2c/luatexdir/pdf/pdfdest.c
@@ -405,7 +405,7 @@ int output_name_tree(PDF pdf)
         }
     }
   DONE:
-    if ((dests != 0) || (pdf_names_toks != null)) {
+    if ((dests != 0) || (pdf_names_toks != null) || (get_pdf_table_string("names") != null)) {
         m = pdf_create_obj(pdf, obj_type_others, 0);
         pdf_begin_obj(pdf, m, OBJSTM_ALWAYS);
         pdf_begin_dict(pdf);
diff --git a/source/texk/web2c/luatexdir/pdf/pdfgen.c b/source/texk/web2c/luatexdir/pdf/pdfgen.c
index 2f288fac5..9ed47cc9e 100644
--- a/source/texk/web2c/luatexdir/pdf/pdfgen.c
+++ b/source/texk/web2c/luatexdir/pdf/pdfgen.c
@@ -1678,6 +1678,7 @@ void pdf_begin_page(PDF pdf)
         form_margin = obj_xform_margin(pdf, pdf_cur_form);
         if (xform_attributes != null)
             pdf_print_toks(pdf, xform_attributes);
+        print_pdf_table_string(pdf, "xformattributes");
         if (obj_xform_attr(pdf, pdf_cur_form) != null) {
             pdf_print_toks(pdf, obj_xform_attr(pdf, pdf_cur_form));
             delete_token_ref(obj_xform_attr(pdf, pdf_cur_form));
@@ -1963,6 +1964,7 @@ void pdf_end_page(PDF pdf)
         if (xform_resources != null) {
             pdf_print_toks(pdf, xform_resources);
         }
+        print_pdf_table_string(pdf, "xformresources");
         if (obj_xform_resources(pdf, pdf_cur_form) != null) {
             pdf_print_toks(pdf, obj_xform_resources(pdf, pdf_cur_form));
             delete_token_ref(obj_xform_resources(pdf, pdf_cur_form));

Reply via email to